The Messenger of Allah ﷺ passed by him during the time of Hudaybiyah and said, "The lice on your head are troubling you?"He replied, "Yes."The Prophet ﷺ said, "Shave your head, then either slaughter a sheep as a sacrifice, or fast three days, or feed six poor people with three saa of dates."
حدثنا وهب بن بقية عن خالد الطحان عن خالد الحذاء عن أبي قلابة عن عبد الرحمن بن أبي ليلى
أن رسول الله ﷺ مر به زمن الحديبية فقال قد آذاك هوام رأسك قال نعم فقال النبي ﷺ احلق ثم اذبح شاة نسكا أو صم ثلاثة أيام أو أطعم ثلاثة آصع من تمر على ستة مساكين
Sourced by Muslim, Hajj, chapter on the permissibility of shaving the head for one in a state of ihram if he has an ailment, etc., hadith 84/1201, from the hadith of Khalid Tahhan, and Bukhari, chapter on those prevented from completing Hajj, chapter on the saying of Allah Almighty, "but whoever among you is ill or has an ailment of the head..." etc., hadith 1814, from the hadith of Abdul-Rahman bin Abu Layla through him.