كتاب الحج
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 d

Ka'b b. 'Ujra (Allah be pleased with him) reported that the Messenger of Allah (may peace be, upon him) stood near him and lice were falling from his head. Thereupon he (the Holy Prophet) said:

Do these vermins trouble you? I said: Yes. Thereupon he said: Then shave your head; and it was in connection with me that this verse was revealed:" Whoever among you is sick or has an ailment of the head, he (may effect) a compensation by fasting or alms or a sacrifice". He (the Holy Prophet, therefore) said to me: Observe fast for three days or give a quantity of alms enough to feed six needy persons or offer sacrifice (of an animal) that is available.
وَحَدَّثَنَا ابْنُ نُمَيْرٍ، حَدَّثَنَا أَبِي، حَدَّثَنَا سَيْفٌ، قَالَ سَمِعْتُ مُجَاهِدًا، يَقُولُ حَدَّثَنِي عَبْدُ، الرَّحْمَنِ بْنُ أَبِي لَيْلَى حَدَّثَنِي كَعْبُ بْنُ عُجْرَةَ، - رضى الله عنه - أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم وَقَفَ عَلَيْهِ وَرَأْسُهُ يَتَهَافَتُ قَمْلاً فَقَالَ ‏"‏ أَيُؤْذِيكَ هَوَامُّكَ ‏"‏ ‏.‏ قُلْتُ نَعَمْ ‏.‏ قَالَ ‏"‏ فَاحْلِقْ رَأْسَكَ ‏"‏ ‏.‏ قَالَ فَفِيَّ نَزَلَتْ هَذِهِ الآيَةُ ‏{‏ فَمَنْ كَانَ مِنْكُمْ مَرِيضًا أَوْ بِهِ أَذًى مِنْ رَأْسِهِ فَفِدْيَةٌ مِنْ صِيَامٍ أَوْ صَدَقَةٍ أَوْ نُسُكٍ‏}‏ فَقَالَ لِي رَسُولُ اللَّهِ صلى الله عليه وسلم ‏"‏ صُمْ ثَلاَثَةَ أَيَّامٍ أَوْ تَصَدَّقْ بِفَرَقٍ بَيْنَ سِتَّةِ مَسَاكِينَ أَوِ انْسُكْ مَا تَيَسَّرَ ‏"‏ ‏.‏
Reference : Sahih Muslim 1201d
In-book reference : Book 15, Hadith 90
USC-MSA web (English) reference : Book 7, Hadith 2735
  (deprecated numbering scheme)