Your situation can be stated as Voiding Dysfunction or Eneuresis (Nocturnal-Night dribbling/bed wetting, Diurnal-day time wetting),which has following symptoms like- Urinary incontinence,Dribbling (involuntary or automatic urine leakage),hesitancy and urgency and also mild burning sensation during mid stream or end stream of urine.People who often have these symptoms have a annoying / embarrassing situation,which has remnants of urine/semen leakage which is observed as pungent smell like rose petals or sweet smell in case of diabetes, ammonia like smell in case or Non complicative Urinary tract infection.
These symptoms can indicate pathological conditions of Urinary Bladder like Overactive bladder,Urinary incontinence due to Detrusor muscle incompetence or bladder sphincter incompetence, more commonly due to Recuurent Kidney stones or uncomplicated Urinary Tract infections or totally idiopathic/ Functional incompetence due to anxiety or stress. Masturbation may trigger urge for urination when peaks of orgasm is achieved.But this can be controlled through proper technique of masturbation or through 'Press and Squeeze technique' or Male Kegel's exercise- training of pelvic muscles to control urine flow and ejaculation.
But before any proper management,you condition must be ruled to see what causes this abnormal urine leakage.This can be done through Complete urine Examination, Pelvic USG for Renal/Bladder, Urethrogram, Urodynamic tests- test for passage of urine in a given time, Physical and Neurological examination-find anatomical abnormalities, Social/ Medical History and observation-Psychological/physiological and performance related issues,which will not only rule out each and every disorder related to Male Urogenital system.
So talk to your consulting Urologist or Attending Physician and have a complete evaluation done to eliminate each and every potential cause of this Urinary Voiding Dysfunction.
Please keep us updated,mention any doubts if this explanation does not clear it.All The Best!