Hi there,
It’s always better to have a detailed medical and psychiatric history of every case. In addition, a detailed mental status examination is needed to come for a diagnosis and the management of the case accordingly.
Anyways, some advice can be given for your friends problem.
In this world easy availability almost every “ knowledge on the media, a large number of men of your age come for this type of problems.
Next Steps
There is a need to get psycho education on the topic of Sex and topics like masturbation.
It is very easy to fall for any activity that gives pleasure but later” repenting “ and getting in “ guilt” in indulging in them.
Psychological interventions might help like avoiding “cues” about sex, sexual activities and reducing the time for these topics on internet.
Keeping busy with healthy activities like reading ,meditation and yoga exercises etc.
But still medications are likely to be needed in his case in addition to the psychological interventions.
As there is a history of OCD in the family, Psychophysical interventions will be needed.
Be positive in your thoughts.You are not alone in this world with this problem.
Contact a mental health professional.