Yes, your surgery may have played a role in your urinary tract infection (UTI).
Many patients have a catheter inserted into their bladder to drain urine during and/or after their procedure. The presence of a catheter, even a temporary one, increases the risk of contracting a urinary tract infection.
A condition called urinary retention is also common after anesthesia, and can increase the likelihood of a UTI. Urinary retention means that the bladder does not fully empty during urination, leaving urine sitting in the bladder longer than is normal. This can be minor, leading to urinary frequency, or more serious, requiring catheterization and additional treatment.
There are additional factors that may play a role in a UTI after surgery, including the age of the patient (older patients are more likely to have this complication), gender (women are most likely to have a UTI), type of surgical procedure and other conditions that you may have. Diabetes increases the risks of a UTI, as do surgeries that are done on or near part of the urinary tract, such as a prostate surgery.
Additionally, being immobilized after surgery will increase the probability of a UTI. Immobility is common after trauma, and orthopedic procedures including some joint surgeries.
Urinary Tract Infection - Adults. MedlinePlus. Accessed March 2011. http://www.nlm.nih.gov/medlineplus/ency/article/000521.htm