Thanks for your query.Based on the facts that you have posted it appears that you are passing blood in the Urine what is called as Hematuria
There are many causes of hematuria which needs be investigated.It could be due to simple UTI or due to stones in Urinary system
or due to tumour .
This can be confirmed only on doing following investigations like
scanning of the Abdomen
2) Contrast C.T.Scan of the kidney ,Ureter and Bladder.
3) Endoscopic examination of Bladder.
However it is never due to excessive masturbation
Do not worry get these test done and relax.