I usually Vaseline the area when it's like this, and use wet toilet wipes. It's possibly piles, and sometimes even if they're not visible they can be just inside.
When this happens to me I use a good amount of Vaseline just before a bowel movement, this helps create a barrier so the sore part doesn't get irritated and helps with the stretch. Very graphic, but I'm being honest. And usually within 3-4 days the soreness has gone. I'd let your GP prescribe you something if its not helped within a few days, and to check it's not perianal disease.
Good luck!