كتاب الحج
15  
The Book of Pilgrimage
(10)
Chapter: It is permissible for a Muhrim to shave his head if there is a problem, but it is obligatory to offer a Fidyah for shaving it, and Clarifying what the Fidyah is
(10)
باب جَوَازِ حَلْقِ الرَّأْسِ لِلْمُحْرِمِ إِذَا كَانَ بِهِ أَذًى وَوُجُوبِ الْفِدْيَةِ لِحَلْقِهِ وَبَيَانِ قَدْرِهَا
Sahih Muslim 1201 h

Ka'b b. Ujra (Allah be pleased with him) reported that he went out with the Messenger of Allah (ﷺ) in the state of Ihram, and his (Ka'b's) head and beard were infested with lice. This was conveyed to the Messenger of Allah (ﷺ). He sent for him (Ka'b) and called a barber (who) shaved his head. He (the Holy Prophet) said. Is there any sacrificial animal with you? He (Kalb) said:

I cannot afford it. He then commanded him to observe fasts for three days or feed six needy persons, one sa' for every two needy persons. And Allah the Exalted and Majestic revealed this (verse) particular with regard to him:" So whosoever among you is sick and has an ailment of the head.." ; then (its application) became general for the Muslims.
وَحَدَّثَنَا أَبُو بَكْرِ بْنُ أَبِي شَيْبَةَ، حَدَّثَنَا عَبْدُ اللَّهِ بْنُ نُمَيْرٍ، عَنْ زَكَرِيَّاءَ بْنِ أَبِي زَائِدَةَ، حَدَّثَنَا عَبْدُ الرَّحْمَنِ بْنُ الأَصْبَهَانِيِّ، حَدَّثَنِي عَبْدُ اللَّهِ بْنُ مَعْقِلٍ، حَدَّثَنِي كَعْبُ بْنُ عُجْرَةَ، - رضى الله عنه - أَنَّهُ خَرَجَ مَعَ النَّبِيِّ صلى الله عليه وسلم مُحْرِمًا فَقَمِلَ رَأْسُهُ وَلِحْيَتُهُ فَبَلَغَ ذَلِكَ النَّبِيَّ صلى الله عليه وسلم فَأَرْسَلَ إِلَيْهِ فَدَعَا الْحَلاَّقَ فَحَلَقَ رَأْسَهُ ثُمَّ قَالَ لَهُ ‏"‏ هَلْ عِنْدَكَ نُسُكٌ ‏"‏ ‏.‏ قَالَ مَا أَقْدِرُ عَلَيْهِ ‏.‏ فَأَمَرَهُ أَنْ يَصُومَ ثَلاَثَةَ أَيَّامٍ أَوْ يُطْعِمَ سِتَّةَ مَسَاكِينَ لِكُلِّ مِسْكِينَيْنِ صَاعٌ فَأَنْزَلَ اللَّهُ عَزَّ وَجَلَّ فِيهِ خَاصَّةً ‏{‏ فَمَنْ كَانَ مِنْكُمْ مَرِيضًا أَوْ بِهِ أَذًى مِنْ رَأْسِهِ‏}‏ ثُمَّ كَانَتْ لِلْمُسْلِمِينَ عَامَّةً ‏.‏
Reference : Sahih Muslim 1201h
In-book reference : Book 15, Hadith 94
USC-MSA web (English) reference : Book 7, Hadith 2739
  (deprecated numbering scheme)