Such kind of sharp testicular pain can be due to torsion testis and it needs to be ruled out as soon as possible because it is a medical emergency. Other causes are excessive bicycle riding, hernia
or kidney or ureteric stones. Some causes of testicle pain, including testicular torsion, can lead to infertility
if not treated promptly. Infections also should be examined and treated right away.
I hope it helps. Take care and regards.