You can't always prevent a testicle injury, but these steps will help protect you:
Wear a jockstrap when you're playing sports. If you're doing an activity that could lead to a hard strike -- such as baseball or martial arts -- also wear a protective cup. Be sure the cup fits well and is properly placed over your penis and testicles.
Wear your seat belt while in a vehicle.
Use caution when riding motorcycles and bicycles.
Take care near machinery that could snag your clothing or skin. Avoid loose clothing and belts. Follow all safety rules while using machinery.