Answered by Sayyidi Habib Umar bin Hafiz (may Allah protect him and benefit us by him)
What can people recite to cure addiction or to help them leave bad habits?
They should recite the following dhikr at least 300 times a day. The stronger the habit the more dhikr is needed.
يا حَيُّ يَا قَيَّومُ بِرَحْمَتِكَ أَسْتَغِيثُ ومِنْ عَذابِكَ أسْتَجِيرُ
أَصْلِحْ لِي شَأنِي كُلَّهُ ولاَ تَكِلْنِي إلى نَفْسِي وَلا إِلى أَحَدٍ مِن خَلْقِكَ طَرْفَةَ عَينٍ
Ya Hayyu ya Qayyum bi rahmatika astaghith wa min ‘adhabika astajir, aslih li sha’ni kullah wa la takilni ila nafsi wa la ila ahadin min khalqika tarfata ‘ayn
O Living! O Sustainer! I call upon Your Mercy for assistance, and from Your punishment I seek refuge! Make good all my affairs and do not entrust me to myself or any of Your creation even for the blink of an eye.
Also reflect on the return to Allah and long to meet the Prophet ﷺ . You must then avoid places that arouse in you the desire to return to that habit and if you do feel that desire you should remember Allah and the next life. You should keep the company of those who remind you of Allah and those with whom you find tranquillity.