It happens at times especially when you masturbate vigorously, it decreases the sensitivity of your penis and as a result of it when you get involved in sexual intercourse you don't get the stimulation which you are accustomed to, and consequently you start loosing erection early. Other reason could be performance anxiety.
Next Steps
You should try spending more time in foreplay (for atleast 15-20 mins) and try different positions of sexual intercourse, especially the ones having maximal penile stimulation (you can find same over web), if nothing works, consult a psychiatrist and get yourself assessed for anxiety disorder
Health Tips
Stop masturbation at all if you have a partner available for sexual intercourse