كتاب الأيمان
27  
The Book of Oaths
(3)
Chapter: It is recommended for the one who swears an oath then sees that something else is better than it; To do that which is better and offer expiation for his oath
(3)
باب نَدْبِ مَنْ حَلَفَ يَمِينًا فَرَأَى غَيْرَهَا خَيْرًا مِنْهَا أَنْ يَأْتِيَ الَّذِي هُوَ خَيْرٌ وَيُكَفِّرَ عَنْ يَمِينِهِ
Sahih Muslim 1650 b

Abu Huraira reported Allah's Messenger (ﷺ) as saying:

He who took an oath and then found another thing better than (this) should expiate for the oath (broken) by him and do (the better thing).
وَحَدَّثَنِي أَبُو الطَّاهِرِ، حَدَّثَنَا عَبْدُ اللَّهِ بْنُ وَهْبٍ، أَخْبَرَنِي مَالِكٌ، عَنْ سُهَيْلِ بْنِ أَبِي، صَالِحٍ عَنْ أَبِيهِ، عَنْ أَبِي هُرَيْرَةَ، أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم قَالَ ‏ "‏ مَنْ حَلَفَ عَلَى يَمِينٍ فَرَأَى غَيْرَهَا خَيْرًا مِنْهَا فَلْيُكَفِّرْ عَنْ يَمِينِهِ وَلْيَفْعَلْ ‏"‏ ‏.‏
Reference : Sahih Muslim 1650b
In-book reference : Book 27, Hadith 19
USC-MSA web (English) reference : Book 15, Hadith 4053
  (deprecated numbering scheme)