كتاب الْمَسَاجِدِ وَمَوَاضِعِ الصَّلاَةِ
5  
The Book of Mosques and Places of Prayer
(54)
Chapter: It is recommended to say qunut in all prayers if a calamity befalls the Muslims – and refuge is sought from Allah (regarding that). It is recommended to say qunut in Subh at all times. And the clarification that it is to be said after raising the head from bowing in the final rak`ah, and it is recommended to say it out loud
(54)
باب اسْتِحْبَابِ الْقُنُوتِ فِي جَمِيعِ الصَّلاَةِ إِذَا نزَلَتْ بِالْمُسْلِمِينَ نَازِلَةٌ ‏‏
Sahih Muslim 675 c

Abu Salama reported it on the authority of Abu Huraira that the Messenger of Allah (ﷺ) recited Qunut after ruku' in prayer for one mouth at the time of reciting (these words):

" Allah listened to him who praised Him," and he said in Qunut:" 0 Allah! rescue al-Walid b. al-Walid; O Allah! rescue Salama b. Hisham; O Allah! rescue 'Ayyash b. Abu Rabi'a; O Allah! rescue the helpless amongst the Muslims; O Allah! trample Mudar severely; O Allah! cause them a famine like that (which was caused at the time) of Joseph." Abu Huraira (further) said: I saw that the Messenger of Allah (ﷺ) afterwards abandoned this supplication. I, therefore said: I see the Messenger of Allah (ﷺ) abandoning this blessing upon them. It was raid to him (Abu Huraira): Don't you see that (those for whom was blessing invoked by the Holy Prophet) have come (i. e. they have been rescued)?
حَدَّثَنَا مُحَمَّدُ بْنُ مِهْرَانَ الرَّازِيُّ، حَدَّثَنَا الْوَلِيدُ بْنُ مُسْلِمٍ، حَدَّثَنَا الأَوْزَاعِيُّ، عَنْ يَحْيَى بْنِ أَبِي كَثِيرٍ، عَنْ أَبِي سَلَمَةَ، أَنَّ أَبَا هُرَيْرَةَ، حَدَّثَهُمْ أَنَّ النَّبِيَّ صلى الله عليه وسلم قَنَتَ بَعْدَ الرَّكْعَةِ فِي صَلاَةٍ شَهْرًا إِذَا قَالَ ‏"‏ سَمِعَ اللَّهُ لِمَنْ حَمِدَهُ ‏"‏ ‏.‏ يَقُولُ فِي قُنُوتِهِ ‏"‏ اللَّهُمَّ أَنْجِ الْوَلِيدَ بْنَ الْوَلِيدِ اللَّهُمَّ نَجِّ سَلَمَةَ بْنَ هِشَامٍ اللَّهُمَّ نَجِّ عَيَّاشَ بْنَ أَبِي رَبِيعَةَ اللَّهُمَّ نَجِّ الْمُسْتَضْعَفِينَ مِنَ الْمُؤْمِنِينَ اللَّهُمَّ اشْدُدْ وَطْأَتَكَ عَلَى مُضَرَ اللَّهُمَّ اجْعَلْهَا عَلَيْهِمْ سِنِينَ كَسِنِي يُوسُفَ ‏"‏ ‏.‏ قَالَ أَبُو هُرَيْرَةَ ثُمَّ رَأَيْتُ رَسُولَ اللَّهِ صلى الله عليه وسلم تَرَكَ الدُّعَاءَ بَعْدُ فَقُلْتُ أُرَى رَسُولَ اللَّهِ صلى الله عليه وسلم قَدْ تَرَكَ الدُّعَاءَ لَهُمْ - قَالَ - فَقِيلَ وَمَا تَرَاهُمْ قَدْ قَدِمُوا
Reference : Sahih Muslim 675c
In-book reference : Book 5, Hadith 375
USC-MSA web (English) reference : Book 4, Hadith 1430
  (deprecated numbering scheme)