From Sahih Muslim (Hadith 4277):
Adi reported Allah's Messenger (ﷺ) as saying:When anyone amongst you takes an oath, but he finds (something) better than that he should expiate (the breaking of the oath), and do that which is better
Reference: Muslim 4277