Thank you for your query.
Masturbation is not the cause of your erection problem. Rather you can use masturbation techniques and pelvic floor exercises to increase duration of erection. However before you try anything else you need some basic tests to rule out problems that can cause ED., for example tests for
diabetes,
thyroid, other endocrine tests,
lipid profile ECG etc. Your doctor can help with these. If they are all normal you can proceed with masturbation exercises and also use medicines. Be aware that medicines like Viagra also need you to stimulate the penis and you do have side effects like headaches. So first try without medicines.
Try the book ' managing erectile dysfunction' by Metz and McCarthy
hope this helps