´'Abdur-Rahman bin Samurah said:` "The Messenger of Allah said to me: 'If you swear an oath, then you see something that is better, do that which is better, and offer expiation for your oath.'"
Related hadith on this topic
Explanation & Benefits
Shaykh Umar Farooq Saeedi
Benefits and Issues:
If someone has taken an oath, but there is a Shari‘ah-based or moral benefit in acting contrary to it, then one should act upon the better course.
And the expiation (kafarah) for the oath should be given.
And there is flexibility in this matter: one may give the expiation before or after (breaking the oath).
Source: Sunan Abu Dawood – Commentary by Shaykh Umar Farooq Saeedi, Page: 3277