Generally after passing hard stools, there will be micro-cracks in the anal mucosa which will cause the pain and burning sensation after defecating.
Avoid constipation/hard stools by increasing fibre in your diet and drinking adequate water.
Next Steps
You can take De-worming tablet which will help if you have worm infestation as this causes anal itch as well.
Health Tips
If in case you are passing blood in stools, consult a physician in your town for further evaluation.