Alone spent a lot of time writing about masturbation as a symptom of narcissism, most classically in this post. I can’t say it better than he can so I’m not going to try. I’m not a urologist, either; caveat emptor.
What I can do is offer you the first step towards a (re)solution of this problem. If you are a young man in your 20s and 30s who is in a long term relationship and can’t get it up with your girlfriend/wife you don’t need viagra. After years on the pornotron what you need to do is to spend at least three days masturbating without it. Of course longer = better, because that’s how this math always works, but three days seems to be the minimum amount of effort to make a difference.
Return to your imagination. Don’t replay the video you like in your mind’s eye, this is cheating and it won’t work. Fantasize about an erotic scene. Perhaps replay a real one from your youth, maybe with a new spin. The point is to begin to learn how to want. If we have to do this in the context of vice, well, there are worse places to begin from. If you do this, and stick with it for a bit, you’ll find it’s easier to get aroused with your loved one (even if you don’t decrease the amount of times you actually masturbate).
I said this was for young men, will it work if you’re older? Sure, but the prognosis is much more hopeless for you than it is for them. Better to stick with what you know. The issues and work of middle adulthood are not the same as young adulthood. I also think the DSM should revise the diagnosing of personality disorders to 40 years old rather than 18, but that’s a topic for another time.