One should recite the following duaa before going to sleep
بِسْمِ اللَّهِ وَضَعْتُ جَنْبِى اللَّهُمَّ اغْفِرْ لِى ذَنْبِى وَأَخْسِئْ شَيْطَانِى وَفُكَّ رِهَانِى وَاجْعَلْنِى فِى النَّدِىِّ الأَعْلَى
In the name of Allah Ta’ala have I placed my side down (i.e. I have lay down to sleep), O Allah, forgive my sins, repel my shaytaan from me, and free me (from my burdens and worries), and make me amongst the exalted gathering of servants.
عن أبى الأزهر الأنمارى أن رسول الله صلى الله عليه وسلم كان إذا أخذ مضجعه من الليل قال: بسم الله وضعت جنبى اللهم اغفر لى ذنبى وأخسئ شيطانى وفك رهانى واجعلنى فى الندى الأعلى (ابو داود رقم 5056)
Hadhrat Abul Azhar Anmaari (Radhiallahu Anhu) reports that when Rasulullah (Sallallahu Alaihi Wasallam) would retire to bed, he would recite the following duaa:
بِسْمِ اللَّهِ وَضَعْتُ جَنْبِى اللَّهُمَّ اغْفِرْ لِى ذَنْبِى وَأَخْسِئْ شَيْطَانِى وَفُكَّ رِهَانِى وَاجْعَلْنِى فِى النَّدِىِّ الأَعْلَى