My husband had a knee surgery on june 16th and he has been suffering from diarrhea since then. This was the1st time he had anesthesia. The pain medicine was motrin 800mg. What should I do?

Talk to MD. Most likely this is not related to the anesthesia or the pain medications. It is possible that the dose of antibiotics used has disturbed the normal gut flora. Consider taking some lactobacillus containing yogurt to try and stabilize this flora. If it continues talk to md.
Let surgeon know. Surgeons give routine prophylactic antibiotics before these procedures (cephazolin) that can cause diarrhea by killing off the good bacteria in the gut. It is known as c. Difficile colitis and can be diagnosed and treated. Sometimes Ibuprofen can cause diarrhea, try stopping it and any otc pain med except for tylenol (acetaminophen) and see what happens. Probiotics can help symptoms by replacing good bacteria.
Diarrhea. After hospitalization during which he probably received antibiotics at least prophylactically and was also exposed to hospital bacteria he may have gotten clostridium difficile colitis and should be checked for this, along with other causes. If the surgeon is unsure have him get an infectious diseases expert in consultation. This definitely needs to be evaluated. Good luck and hope things work out.