Sorry for the late reply. I'm just flipping through these.
If you get erections during masturbation, you can get erections. That's just a fact.
I'd start keeping a log about the morning erections. I'd bet you're currently noticing a lack of them, but you need hard data. As for the night ones, dude, you're asleep when they happen. Don't make any assumptions unless you wear something that monitors them (yeah, they make these things).
It sounds like you've developed a form of performance anxiety, or at least "performance expectation". When you're trying to have sex, are you thinking about the problem? I would bet you are. That's not going to help.
I'd cut back on the jerking off and the porn. Only to bring up the urge a bit. Personally, I do at least once a day, and I'm 31. I've already done it twice today, and I'll probably have another round later. Don't worry about that too much, but for now, give that a shot.
I had a very similar situation as you. first real relationship at about 23. Erections, except when it was time for sex. A little overweight, smoker, etc. Even with all those bad marks, as soon as I got past the performance anxiety, I could smoke a pack of cigarettes, be really hung over, haven't hit the gym is 6 months, and still go 3 rounds in a night. It was all in my head.
If you're thinking about it a lot, the harder you try, the worse its going to be. Here's what I did:
1) The first girl and I broke up. Didn't date for a year.
2) New girl, same problem. However, I had learned a bunch (the internet rules). Sat down and explained that I'm just worried about it and we need to relax and try to make it work.
3) After a few sessions, did just barely get it to happen. Next time, a lot better. After that, she got annoyed because she has a significantly lower sex drive than I did.
Yo noted that you aren't that excited around her. You should consider that deep down you are probably anticipating problems, and that will kill excitement. This has happened to me. If the girl digs you, I'd suggest you told her exactly what I said. Its just a temporary situation, mostly subconscious. After you get some "success", things will be better. Instead of trying to have sex, do other stuff. Oral, etc. Have fun. Try your best to keep it from being a "big deal". Some girls are relaxed and can accept that guys aren't perfect sex machines. Some girls internalize it. "Oh, he must not be attracted to me". Etc. Since she's joking about it, she's probably the former.
Joking about it, by the way, might hurt, but I'd try that. Make a joke about it yourself, especially when you're both fooling around. Its a tough thing while its going on, but after you sort it out, you'll look back and almost laugh about it. Almost.