It becomes obligatory to break the oath when a person has sworn to abandon a duty—such as cutting off his kinship ties—or has sworn to commit a forbidden act—such as pledging, “I will surely drink wine.” In such cases he must break the oath and offer the expiation required for broken oaths.
Conversely, it is unlawful to break an oath when one has sworn to avoid a prohibited act or to perform a duty; here he is obliged to keep the oath and may not undo it.
Breaking the oath is merely permissible when the oath concerns a neutral matter—something originally permitted—whether one has sworn to do it or to refrain from it.
The Prophet ﷺ said, “Whenever I swore an oath and then realized that something else was better, I would do what is better and make expiation for my oath.” He also said, “Whoever swears an oath and then sees an alternative that is better, let him do what is better and expiate for his oath.”
If a person declares some lawful thing—other than his wife—unlawful for himself, such as food, drink, or clothing, saying, for example, “What Allah has made lawful is forbidden to me,” or “This food is forbidden to me,” that item does not in fact become forbidden; he may still partake of it, but he must pay the expiation for a broken oath. Allah the Exalted says: “O Prophet, why do you forbid what Allah has made lawful for you, seeking to please your wives…,” and He says shortly thereafter: “Allah has already ordained for you the dissolution of your oaths”—meaning the expiation required when someone forbids for himself what is lawful.