When I have sex in my vagina my anus hurts what could be the problem?

May be nothing. Pl get checked by your PMD or OB to rule out a few conditions like a rectocele or small hemorrhoids, which may be internal if not actively bleed. Feel better.