That Messenger of Allah ﷺ saw him with the lice falling (from his head) on his face. Messenger of Allah ﷺ said, "Are your lice troubling you? Kaʿb said, "Yes." Messenger of Allah ﷺ thus ordered him to shave his head while he was at Al-Hudaibiya. Up to then there was no indication that all of them would finish their state of Ihram and they hoped that they would enter Mecca. Then the order of Al-Fidya was revealed, so Messenger of Allah ﷺ ordered Kaʿb to feed six poor persons with one Faraq of food or slaughter a sheep or fast for three days. (Using translation from Bukhārī 4159)
أَنَّ رَسُولَ اللهِ ﷺ رَآهُ وَالْقُمَّلُ يَسْقُطُ عَلَى وَجْهِهِ فَقَالَ لَهُ أَيُؤْذِيكَ هَوَامُّكَ؟ قَالَ نَعَمْ فَأَمَرَهُ أَنْ يَحْلِقَ قَالَ وَهُمْ بِالْحُدَيْبِيَةِ لَمْ يَتَبَيَّنْ لَهُمْ أَنَّهُمْ يَحِلُّونَ بِهَا وَهُمْ عَلَى طَمَعٍ مِنْ دُخُولِ مَكَّةَ فَأَنْزَلَ اللهُ الْفِدْيَةَ وَأَمَرَهُ رَسُولُ اللهِ ﷺ أَنْ يُطْعِمَ فَرَقًا بَيْنَ سِتَّةِ مَسَاكِينَ أَوْ صَوْمُ ثَلَاثَةِ أَيَّامٍ أَوْ نُسُكُ شَاةٍ