Welcome to HealthcareMagic forum.
Pain in the testes could be due to many causes like torsion of testes which is more acute and sudden, epididymitis
,any trauma to testes,following a viral infection they get inflammed called orchitis
,any abdominal infections and even a kidney
stone could radiate the pain.
In your case as it is intermittent more likely to be epididymitis. You need a course of antibiotics for the same , it will be fine in 3 weeks .
If the pain gets very severe, it needs immediate review just keeping torsion in mind, being an emergency
Wish you good health