When a guy gets a testicule exam from his doctor, why does the doctor ask him to cough?

Check for hernia. The cough invokes a valsalva response which increases the pressure inside your abdomen which could make a hidden asymptomatic hernia present itself. We ask you to turn your head before coughing so that you don't cough directly on us!