Hello and welcome to e health forum.
From the history given, it seems that your issues could be due to psychological causes (Stress and performance anxiety).
Good sex , needs a prepared and relaxed brain. When in stress or when self doubt takes over, the confidence and hence the performance drops.
The best sexual experience is when the couple is confident with their own body and sexuality as well as confident and are having a healthy sexual attraction towards their partner. When such a confidence builds in, then you will find that your issues will be solved.
Since you are able to have a erection with masturbation as well as other means, you might not be having a major cause of ED.
When you dont get erections, it means that your penis needs some time, to get active. This happens often in most males and is not a thing to worry. Probably you are not aroused completely or you are stressed out. In such a situation, instead of beating yourselves up, just relax and cuddle together, for some time.
Seek your partners help for complete stimulation (Mutual masturbation , oral sex, etc can help in sexual arousal).
Watching movies which promote sexual intimacy will also help.
Once you are properly rested and aroused, you will have proper strong erections, and have satisfactory sex.
You might consult your doctor or a sexologist, who can prescribe you medications like cialis and viagra, which when used for a couple of times will help you gain your confidence.
I hope this helps.