This can be due to chronic anal fissure ,some times external hemorrhoids with thrombosis can also cause pain which requires a visit to surgeon or proctologist.
Next Steps
add plenty of fibre in diet to avoid constipation,drink plenty of water
Health Tips
can use cremagel L ointment perianally thrice daily to aliveate pain