I second the thoughts of auntiejessi and would get your prostate checked. That sounds supremely annoying! And since it is new, it's either something going on with the prostate or mental and so narrow that down to fix. Let us know what happens!
Since you didn't mention otherwise, I'm going to assume that you still have your prostate. Men have a sphincter at the base of the penis that closes with erection so that urine doesn't can't pass into the urethra. This means you can't urinate during sex. I mentioned the prostate because some men who've had it removed experience incontinence, which can also happen during sex.
This isn't a common symptom for prostatitis, BPH or prostate cancer, but that would be the first thing I'd get checked. It's not that odd that it doesn't happen when you masturbate, unless you take your time and prolong it. You're usually erect for a longer time with sex than with masturbation, and there's a shorter duration between erection and ejaculation during masturbation than sex.
I'd ask your doctor about testosterone levels, PSA testing (guidelines suggest starting this between 40 and 54, depending on risk factors), and a prostate exam, for starters. I'm sure they'll do some urine testing as well.
Let us know what happens.