Mishkat al-Masabih
Hafsa said that when God’s messenger wanted to go to sleep he put his right hand under his cheek, and would then say three times, "O God, guard me from Thy punishment on the day when Thou raisest up Thy servants." Abu Dawud transmitted it.
وَعَن حَفصةَ رَضِيَ اللَّهُ عَنْهَا أَنَّ رَسُولَ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ كَانَ إِذَا أَرَادَ أَنْ يَرْقُدَ وَضَعَ يَدَهُ الْيُمْنَى تَحْتَ خَدِّهِ ثُمَّ يَقُولُ: «اللَّهُمَّ قِنِي عَذَابَكَ يَوْمَ تَبْعَثُ عِبَادَكَ» . ثَلَاثَ مَرَّاتٍ رَوَاهُ أَبُو دَاوُد
Reference