Whenever the Messenger of Allah ﷺ wished to sleep, he would place his right hand under his cheek and say, "Allah, protect me from Your punishment on the Day You resurrect Your servants," repeating it three times.
حدثنا موسى بن إسمعيل حدثنا أبان حدثنا عاصم عن معبد بن خالد عن سواء
أن رسول الله ﷺ كان إذا أراد أن يرقد وضع يده اليمنى تحت خده ثم يقول اللهم قني عذابك يوم تبعث عبادك ثلاث مرار
Its chain of transmission is hasan. Ahmad reported it, 6:288, and Nasai in Kubra, no. 10598, and in the compilation Amal al-Yawm wal-Layla, no. 762, from the hadith of Abu Aban bin Yazid Attar, with this wording. Aasim is Ibn Bahdala, see no. 2451. Part of the hadith has supporting narrations in Tirmidhi, no. 3398, and elsewhere.