Is there anything I should avoid altogether?
As a general rule you should talk with your doctor about any types sexual activity you should avoid.
Depending on the reason for your surgery you might need to avoid anal intercourse. If you are a woman and have had vaginal reconstructive surgery, you will need your doctor to advise on whether it is safe to resume.
How can I avoid pain during intercourse?
While it can help to experiment with sexual positions that shifts weight away from your ostomy, supporting yourself with a pillow, and the use of sexual lubricants, the most important help is to talk openly with your partner about these changes, and to try not to feel self-conscious because of the operation.
Also remember that there are other ways of having sex than intercourse.