It could be an anal fissure, which is causing this problem or even a hemorrhoid. But they are just the possibilities I am listing and it can be better said after a proctological examination. For now, a sitz bath, a topical anesthetic agent, brisk walking and fiber rich diet is beneficial.
1 Doctor agrees with this answer