Hello,
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, hernia or kidney or ureteric stones.
Pain due to torsion comes suddenly and is severe and acute in nature. Moreover it is often accompanied by nausea and vomiting. Pain in varicocele subsides on lying down. Pain from epididymitis (an infection of the testicle) and other causes usually sets in gradually. Early on, pain due to epididymitis is often just in the area of the epididymis itself.
The final diagnosis can only be made after a thorough physical examination including examination of the abdomen, scrotum, testicles and rectum.
Lab investigations like complete blood examination, urine examination, ultrasound lower abdomen and sometimes a urethral swab will help in diagnosis. You should consult a urologist for this.
I sincerely hope that helps. Take care.
This is something you need to see a urologist about to make sure. All the best.