I can definitely relate. A lot of the anti-porn, anti-masturbation ("nofap") proponents focus on the physical side. It's true that novel masturbation, as its called, can have negative effects on sex - if you habitually make yourself orgasm in a very specific way, that a vagina or mouth is never going to replicate, then that's something you have to deprogram from yourself.
There is definitely a strong mental or psychological aspect though, which I don't believe gets the airtime it deserves, possibly because it's much more complex, unique to each punter, difficult to diagnose and often just as difficult to manage. As this is a semi-anonymous forum, I'm not too proud to admit that there have been times where I've been unable to achieve erection and/or ejaculation from a happy ending. I can masturbate myself just fine, so put a beautiful naked woman into the equation and I should cum even more readily, right? The reality is sometimes the opposite happens.
As others have mentioned, I think the girl can sometimes be too pretty to the point where on some level you can't quite believe your luck (a nice problem to have, I suppose!) - while I'm definitely not a chubby chaser nor have a thing for plain girls, some of my very best punts have been with girls you wouldn't look twice at in the street.
There's also also the time pressure ("Only 5 minutes left in the booking, and I still need to shower, damn, I need to cum now!") and financial pressure ("I spent £xxx on this, if I don't cum then I may as well have stayed at home!") that can rise stress levels and deflate the mood.
Cialis and Viagra can both be used as an aid (consult your GP, I am not a doctor, legal disclaimer, etc etc), and beyond that it's just a process that sometimes resembles blind trial and error: trying to be relaxed, well fed and well rested; be honest with yourself with what women and what sexual activities turn you on; a willingness to try a SP several times to see if familiarity improves performance, and so on.