Please see your Dr.
There are a number of possible causes for rectal pain
; the only way to determine the diagnosis is to see your doctor. Your doctor will need to examine the outside of the anus and will likely need to do a rectal exam as well.
If your doctor does not find a cause, seeing a gastroenterologist (gi specialist) would be the next step.