Assalamu alaikum wa rahmatulahi wa barakatuh,
There numerous things you can do to help yourself in this matter. Your personal situation will also help to determine this to some extent. That is, if you are not yet married, then seek a spouse in order that you can have your needs met appropriately. In the mean time, there are ways that you can help to curb this problem whether you are married or not.
As I’m sure you are aware masturbation is not something that is liked by Allah and therefore you should avoid doing it to avoid the sin and His displeasure. Therefore, you should work on strengthening your connection to Allah. Fulfil your obligations as well as adhering to the sunnah and voluntary acts also. It also recommended in particular for your situation to fast as a means to control such desires.
This will increase your remembrance of Allah. The more you remember Him, the more you will be motivated to please Him. It will also increase your fear of Him and His punishment for sins such as masturbation. Seek repentence for such deeds and seek refuge with Allah.
Aside from strengthening your spiritual connection through acts of worship, also keep yourself busy in meaningful activities. Don’t let there be moments in your day when you have redundant time that gives you the space and time to think about masturbation. Get involved in your local community, do a course or start a new hobby; something that will have you focused long term on something useful and productive. In sha Allah, over time you will have gotten so used to a life without masturbation that you will no longer be focused on it and will have broken the habit for good
Aside from these things, avoid situations that stimulate you need or trigger your desires. Take time to think about times when you do it and see if you notice any pattern; is it at a certain time of day, after doing a particular activity, after visiting a certain place? Once you have identified any potential pattern or trigger to your behaviour then you can find ways to avoid being in these situations at least until you are better able to control yourself.
For example, if it is a result of adverts on TV on content of the things you watch, then avoid watching so much TV or watch things that cause such a reaction, if it is something you turn to when you are alone, then try to be around people as much as possible, if it is something you turn to as a means to bring you joy, seek joy with a more meaningful activity, likewise if it something you do just because you are bored.
Combining these different interventions should in sha Allah send you in the right direction in overcoming your current problem.
Views expressed by hosts/guests on this program (live dialogue, Facebook sessions, etc.) are their own and their appearance on the program does not imply an endorsement of them or any entity they represent.