Hi, I am Dr.Shreyash Mehta MD Community Medicine
My answer shall help you solve your query
First of all let me tell you
masturbation is harmless act.
Pain during or after urination and/or ejaculation is sometimes a symptom of an infection of the urethra, the pathway for urine and semen. This type of infection, known as
urethritis, is one of the more common infections in men.
Besides pain, other symptoms may include a burning sensation during urination or erection and a discharge from the urethral opening at the tip of the penis.
There are several possible causes of urethritis, including
urinary tract infections (UTIs), chlamydia, and
gonorrhea. It is also possible for an infection in your urethrea to travel to your bladder, kidneys,
prostate and/or testes, which could explain the pain you describe.
Additional symptoms of an infection that has moved past your urethra may include swelling or a feeling of "heaviness" in the
scrotum and testes.
Pelvic pain during urination and after ejaculation may also be caused by problems with the prostate, a gland that surrounds the urethra below the bladder and secretes a fluid that forms a major part of ejaculate.
Infection or otherwise, it's important to get medical attention when you experience unexplained pain
My advise is
Drink more water more than 3.5 liters/day
Consult you family physician and follow his advise.