It is narrated from Sayyiduna Ka'b bin Ujrah (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) saw him while lice were falling onto his face, and said: "Are your lice troubling you?" He said: Yes. So he (peace and blessings be upon him) ordered him to shave his head, while they were at al-Hudaybiyah, and at that time it was not clear that they would shave there, for they were hoping to enter Makkah. Then Allah, the Mighty and Majestic, revealed the verse of ransom (fidyah), and the Messenger of Allah (peace and blessings be upon him) ordered him to feed six poor people with a faraq, or to offer a sheep as a sacrificial animal (hady), or to fast three days.
Hadith Referenceالمعجم الكبير للطبراني / باب الكاف / 16265