Well your symptoms suggest something of a fissure in ano, it is a type of ulcer in the inner lining of the anus. Typically it will have a burning kind of pain which can be excruciating at times and lasts for hours after passing stools.
It can be easily managed by ointment and good diet pattern.
Next Steps
Kindly do visit a general surgeon or a proctologist to have a visual inspection of the region.. it is usually self limiting and doesn’t require major intervention.