It may seem like a simple question, tell me about anal sex and surgery, but it really isn't. First, I'm not sure if you are asking if anal sex can lead to surgery or if you are asking if you can have anal sex after having surgery, so we will cover both.
The first question, can anal penetration lead to injury and surgery? Yes. It isn't common, but it is possible to have a serious complications from anal sex. In some cases, a foreign body can become lodged in the rectum and require surgery to be removed. This is typically associated with the use of sex toys or other objects for sexual pleasure, but can also be the result of sexual assault or even the ingestion of a foreign object that gets stuck on its way out of the GI tract.
In other cases, vigorous anal sex, whether it is sexual intercourse or performed with an object, can lead to a serious condition called a rectal perforation. This is when the object punctures a hole in the thin tissue that is the rectal wall. This tear in the wall can then allow stool to leak into other areas of the body, which quickly leads to a serious or even life-threatening infection. The treatment for this type of injury is often surgery.
There is also research that indicates that participating in anal sex can lead to an increased risk of anal cancer which typically leads to surgery, but again, the risk is low.
Now, as for anal intercourse after surgery, that answer is a complicated one. There are multiple reasons why anal sex may not be safe after surgery, and plenty of reasons why it may be perfectly safe to return to your normal sex life after surgery.
If your surgery had nothing to do with your genital or abdominal areas, follow your physician's instructions for your recovery. For example, if you had rotator cuff surgery on your shoulder and your doctor advised that you take it easy for a week, plan on refraining from sex for a week.
If your surgery was abdominal in nature, such as a hysterectomy, and your physician said no sex for 6 weeks, that means anal sex as well as vaginal sex. Why is this the case? Your surgery may have taken place in your abdomen, but there is only a thin membrane between your rectum and your abdomen (the same membrane mentioned before that can become perforated). It isn't a good idea to have either type of sexual intercourse if you have healing internal organs, the pressure and the motion is the problem, not necessarily whether you are having rectal or vaginal intercourse.
Now, if your surgery was done on your rectum, anus or colon, you will need to have a frank conversation with your physician. Only your doctor will know the extent and nature of the surgery and be able to give you a safe time frame for resuming sexual activity. If you had hemorrhoid surgery, rectal surgery, intestinal, anal, prostate, perineal surgery or a procedure that was referred to as a "prolapse" into or out of the rectum, wait until your surgeon says it is ok.
Do not be embarrassed to ask the question. A colon rectal surgeon has likely heard this question dozens if not hundreds of times in the past, do not allow feeling bashful prevent you from getting the information that you need to safely return to your normal sexual activity.
Anal Cancer. American Society of Colon and Rectal Surgeons. Accessed October, 2013. http://www.fascrs.org/patients/conditions/anal_cancer/
Management of Rectal Foreign Bodies. PubMed. Accessed October, 2013. http://www.ncbi.nlm.nih.gov/pubmed/23497492
Vibrator Induced Fatal Rectal Perforation. PubMed. Accessed October, 2013. http://www.ncbi.nlm.nih.gov/pubmed/17726499