Hernias and testical pain are quite common. The nerve to the testicle can get caught in the hernia and become pinched.
Hello,
Apart from hernia, this testicular pain can be due to injury, infection (Epididymitis or Orchitis) or inflammation, testicular torsion -- most common in young men between 10 and 20 years old, excessive bicycle riding, kidney or ureteric stones.
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.
It is very difficult to precisely confirm a diagnosis without examination and investigations and the answer is based on the medical information provided. For exact diagnosis, you are requested to consult your dermatologist. I sincerely hope that helps. Take care and please do keep me posted on how you are doing.