With anal play you need plenty of foreplay and prep time. For each encounter you'll probably need non-anal foreplay (to just raise your sexual excitement level), anal foreplay starting with non-penetrative and ending with penetration (to relax, lube and prepare your anus), and prep to make sure you are confident.
Prep may include enemas for each session, because if you're worried about poop/mess then you might not be able to relax. Prep can also include self-play and wearing a buttplug for a while to get your anus accustomed to being open.
Prep also includes a period of time (probably weeks/months) before you do pegging at all, or even partner play. This time allows you to get to know your anus, learn to enjoy the sensations and relax your voluntary muscles, and then you slowly bring your partner in so you can learn how it feels with a partner and that you can trust them.
Three good books: Anal Pleasure and Health by Jack Morin, The Ultimate Guide to Prostate Pleasure by Charlie Glickman and Aislinn Emirzian, and The Ultimate Guide to Anal Sex for Women by Tristan Taormino. Yes, the last one says "Woman" in the title, but it's really directed for anyone who has an anus or wants to penetrate one.
A slim possibility (based on your description of the pain starting when thrusting started it isn't likely) is a reaction to the lube. Occasionally I'll have a lube that burns, but that usually starts when it's applied or right when something is inserted (finger, toy). You might try a different lube. Make sure it's nice and thick and good quality.