It is narrated from Hazrat Nafi that Sayyiduna Abdullah bin Umar (may Allah be pleased with them) would not wash his head in the state of Ihram, except when he experienced a wet dream.
Imam Malik, may Allah have mercy on him, said: I heard from the people of knowledge, they used to say: There is no harm if a man washes his head with sidr or potash, etc., after throwing pebbles at Jamrah al-Aqabah, before shaving his head, because when he has thrown the pebbles at Jamrah al-Aqabah, it becomes permissible for him to kill lice, shave his head, remove dirt, and wear clothes.
Hadith Referenceموطا امام مالك رواية يحييٰ / كتاب الحج / 710