You indicate it happens with a one night stand situation. Do you have a regular partner? Could your body be telling you that the one night stand isn't a good thing for you? Or you are nervous about it so mentally you are not there and lose your erection?
anxiety is a huge factor but also you may need some testosterone. Your doc should be able to prescribe it in petro jelly to be applied topically to your glans penis on a regular schedule. It should bring about stronger erections and then your confidence will follow.
Before resorting to Testosterone, I think this sounds more like a 'performance anxiety' situation. Many guys have had this at one time or another, so you're not alone by any means.
A couple of questions:
1) Do you have completely normal erections when masturbating, and no trouble maintaining them? If so, it's likely this is not a physical problem.
2) Do you have normal morning erections? If you wake up with those fairly frequently, then your Testosterone level is probably fine, and again, this would indicate you DON'T have a physical problem.
What I always suggest to guys who may be just a little nervous when with a partner for the 1st time is, tell her you really like her, are very attracted to her & would like to get physical, but that you want to take it a little slow at first. Tell her that you don't want to jump straight to intercourse, that you two can pleasure each other in other ways. If you can satisfy her manually or orally, she'll really appreciate that & probably think you're very considerate of her needs. (I should add, hopefully, she returns the favor!) Then once you've had a couple of sessions like that, you'll both feel much more comfortable with each other in a sexual context & I'll bet when you're ready to move on to intercourse, you won't be so anxious & probably have no problem maintaining an erection.
One final question: How old are you? If you're in your late teens, 20's or 30s, most likely your T-level is fine & you don't need T-therapy. Keep in mind that taking Testosterone has risks - it can actually cause more problems down the road, because your testes may start reducing the amount they produce because your body senses there's already enough. Believe it or not, it can also cause testicular atrophy & even some shrinkage in penis size. SOme guys even experience Gynecomastia - so-called "Mann-Boobs" because the body tries to equalize hormone levels & a significant amount of the T gets converted to Estrogens - obviously NOT a good thing for a guy! It's not a great idea to take supplemental T unless you've had blood tests that have determined both your "Total Testosterone" & "Free" (unbound) T are below normal levels.
OK, well, it may be that there is some physical issue after all. You could ask your regular Dr. for some tests - I would ask to have Total Testosterone tested as well as "Free" T - that is, Testosterone that isn't bound to something else & therefore is circulating & able to affect sex drive, etc. It's also possible there's a problem with blood circulation in the genital area. For an erection to happen, you need the 2 chambers on either side of the penis (the Corpus Cavernosa) to fill with blood, enabling erection. There's also sort of a 'valve' mechanism that shuts off blood flow OUT of the chambers - blood not only needs to flow IN, but also needs to be blocked from flowing back OUT in order to maintain erection, so if there's any issue with that function, it could make maintaining an erection more difficult. If your regular Dr. can't get to the bottom of this, see a Urologist, especially one that deals with male sexual functioning. For now, the good news is, you are still able to have erections, it just seems as if something is interfering with maintaining them. Good luck & hope you get a good diagnosis & effective treatment.