All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
Masturbation is forbidden and you have to sincerely repent to Allah from it and be determined not to return to it again. What would help in this is to fast as much as possible and to earnestly supplicate Allah and seek His Help.
You should stay away from everything that incites your desires, keep company with righteous people, and be persistent in mentioning Allah.
If it happens that you go back to this sin, then repent again and do not give up, until Allah blesses you with a sincere repentance after which you will not return to this act again.
Allah knows best.