Could a varicoselectomy or an inguinal hernia cause epididymitis?

Hernia. Generally speaking, no. The usual predisposing factors for epididymitis are frequent urinary tract infections, sexually transmitted diseases, urinary flow problems from prostatic hypertrophy. In addition, recent surgery, especially in the urogenital region can cause it as well, so theoretically, a recent varicoselectomy could cause it. Best to see a urologist.