(Reporting the speech of Kaʿb bin Umra) Messenger of Allah ﷺ saw him (i.e. Kaʿb) while the lice were falling on his face. He asked (him), "Have your lice troubled you?" He replied in the affirmative. So, he ordered him to get his head shaved while he was at Al-Hudaibiya. At that time they were not permitted to finish their Ihram, and were still hoping to enter Mecca. So, Allah revealed the verses of Al-Fidya. Messenger of Allah ﷺ ordered him to feed six poor persons with one Faraq of food or to slaughter one sheep (as a sacrifice) or to fast for three days.
أَنَّ رَسُولَ اللَّهِ ﷺ رَآهُ وَأَنَّهُ يَسْقُطُ عَلَى وَجْهِهِ فَقَالَ أَيُؤْذِيكَ هَوَامُّكَ قَالَ نَعَمْ فَأَمَرَهُ أَنْ يَحْلِقَ وَهُوَ بِالْحُدَيْبِيَةِ وَلَمْ يَتَبَيَّنْ لَهُمْ أَنَّهُمْ يَحِلُّونَ بِهَا وَهُمْ عَلَى طَمَعٍ أَنْ يَدْخُلُوا مَكَّةَ فَأَنْزَلَ اللَّهُ الْفِدْيَةَ فَأَمَرَهُ رَسُولُ اللَّهِ ﷺ أَنْ يُطْعِمَ فَرَقًا بَيْنَ سِتَّةٍ أَوْ يُهْدِيَ شَاةً أَوْ يَصُومَ ثَلاَثَةَ أَيَّامٍ