Reference : Hisn al-Muslim 103

اللَّهُمَّ إِنَّكَ خَلَقْتَ نَفْسِي
وَأَنْتَ تَوَفَّاهَا،
لَكَ مَمَاتُهَا وَمَحْياهَا،
إِنْ أَحْيَيْتَهَا فَاحْفَظْهَا،
وَإِنْ أَمَتَّهَا فَاغْفِرْ لَهَا.
اللَّهُمَّ إِنِّي أَسْأَلُكَ العَافِيَةَ
Allāhumma innaka khalaqta nafsī
wa anta tawaffāhā, 
laka mamātuhā wa maḥyāhā, 
in aḥyaytahā faḥfaẓhā, 
wa in amattahā faghfir lahā.
Allāhumma innī as'aluka ‘l-`āfiyah.


O Allah, You have created my soul
and You take it back. 
Unto You is its death and its life. 
If You give it life then protect it, 
and if You cause it to die then forgive it.
O Allah, I ask You for strength.

Reference:
Muslim 4/2083 and Ahmad 2/79.

Chapter: Before sleeping