كتاب الحج
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)
باب جَوَازِ حَلْقِ الرَّأْسِ لِلْمُحْرِمِ إِذَا كَانَ بِهِ أَذًى وَوُجُوبِ الْفِدْيَةِ لِحَلْقِهِ وَبَيَانِ قَدْرِهَا

Ka`b b. 'Ujra (Allah be pleased with him) reported that the Messenger of Allah (ﷺ) happened to pass by him at Hudaibiya before entering Mecca in a state of Ihram and he (Ka'b) was kindling fire under the cooking pot and vermin were creeping on his (Ka`b's) face. Thereupon (the Holy Prophet) said:

Do these vermin trouble you? He (Ka'b) said: Yes. The Messenger of Allah (way peace be upon him) said: Shave your head and give some quantity of food enough to feed six needy persons (faraq is equal to three sa's), or observe fast for three days or offer sacrifice of a sacrificial animal. Ibn Najih (one of the narrators) said:" Or sacrifice a goat."
وَحَدَّثَنَا مُحَمَّدُ بْنُ أَبِي عُمَرَ، حَدَّثَنَا سُفْيَانُ، عَنِ ابْنِ أَبِي نَجِيحٍ، وَأَيُّوبَ، وَحُمَيْدٍ، وَعَبْدِ، الْكَرِيمِ عَنْ مُجَاهِدٍ، عَنِ ابْنِ أَبِي لَيْلَى، عَنْ كَعْبِ بْنِ عُجْرَةَ، - رضى الله عنه - أَنَّ النَّبِيَّ صلى الله عليه وسلم مَرَّ بِهِ وَهُوَ بِالْحُدَيْبِيَةِ قَبْلَ أَنْ يَدْخُلَ مَكَّةَ وَهُوَ مُحْرِمٌ وَهُوَ يُوقِدُ تَحْتَ قِدْرٍ وَالْقَمْلُ يَتَهَافَتُ عَلَى وَجْهِهِ فَقَالَ ‏"‏ أَيُؤْذِيكَ هَوَامُّكَ هَذِهِ ‏"‏ ‏.‏ قَالَ نَعَمْ ‏.‏ قَالَ ‏"‏ فَاحْلِقْ رَأْسَكَ وَأَطْعِمْ فَرَقًا بَيْنَ سِتَّةِ مَسَاكِينَ - وَالْفَرَقُ ثَلاَثَةُ آصُعٍ - أَوْ صُمْ ثَلاَثَةَ أَيَّامٍ أَوِ انْسُكْ نَسِيكَةً ‏"‏ ‏.‏ قَالَ ابْنُ أَبِي نَجِيحٍ ‏"‏ أَوِ اذْبَحْ شَاةً ‏"‏ ‏.‏
Reference : Sahih Muslim 1201 e
In-book reference : Book 15, Hadith 91
USC-MSA web (English) reference : Book 7, Hadith 2736
  (deprecated numbering scheme)