Hi.
Thanks for your query.
Much of the sex is a mind game, they say it is in the brain.
Whether you are masturbating or having actual sex, the pleasure, sensation and ejaculation is all a central phenomenon.
The pain around the testicles may be
referred pain from the congestion of the
prostate. That is why you get it if you are excited but there is no release, that is ejaculation.
So nothing serious about it.
Since you are masturbating for 20 years and have had actual sex with your girlfriend only a few times, it is out of the stress, anxiety or ignorance that you have a problem in ejaculating.
With time and practice every problems settles as will also be in your case.
You can get
ultrasonography and color doppler examination of he abdomen or prostate and
urinary system and of the scrotum for
epididymis and testes.
If there is an infection, you can get a course of an antibiotic.