Hello,
In young males, trauma during masturbation or intercourse, testicular torsion, excessive bicycle riding, hernia or kidney or ureteric stones are the commonest causes of testicular pain. Other than that, infection (Epididymitis or Orchitis) or inflammation also needs to be ruled out.
You can provide support to the scrotum by wearing an athletic supporter, apply ice to the scrotum, take warm baths if there are signs of inflammation, while lying down, place a rolled towel under your scrotum or try over-the-counter pain relievers, like acetaminophen or ibuprofen.
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. If the infection is caused by bacteria, your doctor will prescribe an antibiotic. So please visit your doctor if the symptoms persist.
I sincerely hope that helps. Take care.