I've had inguinal hernia surgery could that cause sterility?

Possible. Unlikely. Sterility requires that both testes, or that both vas deferens (duct from teste that carries sperm) are no longer functional. Injury to the spermatic cord, which contains the vas deferens and blood supply to the teste, is a known complication of inguinal hernia surgery (up to 3%). If you had bilateral operation, or pre-existing problem with opposite teste, then it is possible but very unlikely.
Unlikely. Injury to the channel which carries sperm is possible but very rare. Firtunately, there are two sides and you only need one testicle to be fertile. So you would have to have the other side not functional and the unlikely possibility the surgical side was injured.