Dua #1049•Abu Dawud 2/86, At-Tirmidhi 2/257. Al-Albani graded it authentic in Sahih Abu Dawud 1/283.

Upon committing a sin

Hisnul Muslim
#1049

مَا مِنْ عَبْدٍ يُذنِبُ ذَنْباً فَيُحْسِنُ الطُّهُورَ ثُمَّ يَقُومُ فَيُصَلِّي رَكْعَتَيْنِ ثُمَّ يَسْتَغْفِرُ اللَّهَ إِلاَّ غَفَرَ اللَّهُ لَهُ

Translation

When a servant (of Allah) commits a sin, and he performs ablution well, and then stands and prays two rak'ahs, and asks pardon of Allah, Allah pardons him.