He was with the Messenger of Allah ﷺ in the state of ihram when lice troubled him in his head. The Messenger of Allah ﷺ ordered him to shave his head and said, "Fast three days, or feed six poor people two mudds each, or sacrifice a sheep. Whichever of these you do will suffice for you."
أخبرنا محمد بن سلمة والحارث بن مسكين قراءة عليه وأنا أسمع عن ابن القاسم قال حدثني مالك عن عبد الكريم بن مالك الجزري عن مجاهد عن عبد الرحمن بن أبي ليلى
أنه كان مع رسول الله ﷺ محرما فآذاه القمل في رأسه فأمره رسول الله ﷺ أن يحلق رأسه وقال صم ثلاثة أيام أو أطعم ستة مساكين مدين مدين أو انسك شاة أي ذلك فعلت أجزأ عنك
Its isnad is sahih, and it is found in Muwatta, the narration of Ibn Qasim, no. 409, hadith no. 397, and in Kubra, no. 3834, though the mention of Mujahid is missing from the narration of Muwatta (Yahya), 1/417. Bukhari narrated it, no. 1814, from the hadith of Mujahid, and Muslim, no. 83/1201, from the hadith of Abdul-Kareem, with the same wording.