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

Kalb b. Ujra (Allah be pleased with him) reported:

It was I for whom this verse was revealed (to the Holy Prophet):" Whoever among you is sick or has an ail- ment of the head, he (may effect) a compensation by lasting or alms or a sacrifice" He said: I came to him (the Holy Prophet) and he said: Come Dear. So I went near. He (again) said: Come near. So I went near. Thereupon the Messenger of Allah (ﷺ) said: Do the vermins trouble you? Ibn Aun (one of the narrators) said: I think he (Ka'b b. Ujra) replied in the affirmative. He (the Holy Prophet) then commanded to do compensation by fasting or by giving sadaqa (feeding six needy persons) or by sacrifice (of a animal) that is available.
وَحَدَّثَنَا مُحَمَّدُ بْنُ الْمُثَنَّى، حَدَّثَنَا ابْنُ أَبِي عَدِيٍّ، عَنِ ابْنِ عَوْنٍ، عَنْ مُجَاهِدٍ، عَنْ عَبْدِ الرَّحْمَنِ بْنِ أَبِي لَيْلَى، عَنْ كَعْبِ بْنِ عُجْرَةَ، - رضى الله عنه - قَالَ فِيَّ أُنْزِلَتْ هَذِهِ الآيَةُ ‏{‏ فَمَنْ كَانَ مِنْكُمْ مَرِيضًا أَوْ بِهِ أَذًى مِنْ رَأْسِهِ فَفِدْيَةٌ مِنْ صِيَامٍ أَوْ صَدَقَةٍ أَوْ نُسُكٍ‏}‏ قَالَ فَأَتَيْتُهُ فَقَالَ ‏"‏ ادْنُهْ ‏"‏ ‏.‏ فَدَنَوْتُ فَقَالَ ‏"‏ ادْنُهْ ‏"‏ ‏.‏ فَدَنَوْتُ ‏.‏ فَقَالَ صلى الله عليه وسلم ‏"‏ أَيُؤْذِيكَ هَوَامُّكَ ‏"‏ ‏.‏ قَالَ ابْنُ عَوْنٍ وَأَظُنُّهُ قَالَ نَعَمْ ‏.‏ قَالَ فَأَمَرَنِي بِفِدْيَةٍ مِنْ صِيَامٍ أَوْ صَدَقَةٍ أَوْ نُسُكٍ مَا تَيَسَّرَ ‏.‏
Reference : Sahih Muslim 1201c
In-book reference : Book 15, Hadith 89
USC-MSA web (English) reference : Book 7, Hadith 2734
  (deprecated numbering scheme)