The first and most important cause could be epididiymo orchitis.however it can also be due to torsion or hernia. Torsion is a painful condition. If there is severe pain you should consult a urologist else you can get a urine routine test done to see if it has happened because of a UTI.
Next Steps
Get a urine checkup and visit the Urologist if there is severe pain
Health Tips
Plenty of fluids will be helpful