You are getting into a performance anxiety erectile dysfunction situation. This has nothing to do with your masturbating and everything to do with watching yourself trying to get an erection. Take intercourse off the menu for a while and you will be fine.
To stop masturbation, you can do abdominal breathing (google for details).Do this breathing for 10 minutes twice a day. when there is an urge for sex, take 6 or 7 breaths. This will calm your sexual urge. In this way yo can reduce your masturbation. Experiment with female condom. or lubricated one. Tips on masturbation; use lubricated hand, do not stop breathing, and do not do it in prone position., empty your bladder before doing it......