Welcome to e health forum.
Since you are able to have strong erections regularly or at odd times, then it is probable that that your issues are due to performance anxiety and not due to erectile dysfunction.
Performance anxiety is a very common sexual problem in which men become anxious (mostly a subconsious fright) when it comes time to engage in sexual activity. This results in thought that you may underperform during the act. This results in the lack of spontaneity in flow of sexual feelings and ultimately results in sexual dysfunction.
Almost all men experience it at some point in their lives, But it is more common in adolescents, young adults and inexperienced men with psychological weakness and inability to handle stress.
The way to correct this, is to indulge in sexual activity, when your aim is not just to maintain erections, but is to be the perfect lover for your woman. You will have to leave all your worries and stress all outside the bed room. Just be your self with your partner.
You may also self train yourself with techniques like, stop-start technique , Squeeze technique and kegel exercises which will help to improve your sexual performance.
Realize that you cannot force yourself to have a sexual response, just as you cannot force yourself to go to sleep or to perspire. The harder you try to have a certain sexual response, the harder it becomes to respond.
To reduce the pressure, absorb yourself in the pleasure of the moment. Talk to your partner without any inhibitions. Measures like mutual masturbation, erotic games and adding fun in the time you spend together should help you relax, and improve your sexual performance.
The power of positive thinking can help you accomplish anything, and if you believe that you will have great sex, you will. With patience, a clear mind, and a comfortable relationship with a great woman, you will be able to free yourself of this vicious cycle and you will begin to enjoy sex to the maximum extent.
I hope this helps.