pain the testicles can be due to many reasons like infection,torsion etc.
But,you have to take colour doppler of the scrotum
at the time pain and should exclude INTERMITTENT TESTICULAR TORSION
.Here,testis will be twisted and derotated again so that there will be pain and it is relieved after derotation
It has no relation to masturbation
As all the tests are normal,get Colour doppler of scrotum at the time of pain only
Wish you good health