Sunan Ibn Majah, Book 6, Hadith 133 (Ibn Majah 1565)
It was narrated from Abu Hurairah that the Messenger of Allah (ﷺ) offered the funeral prayer, then he came to the grave of the deceased and scattered three handfuls of earth from the side of (the deceased’s) head.