While wasting food is a bad thing, getting sick is much worse. Our guideline is that a carved pumpkin is only considered food safe for two hours once the inside has been exposed to air. If you’re burning a candle inside of it, the added heat and potential soot issues make it unwise to cook with it at all. The wise counsel of “when in doubt, throw it out” applies here.
That said, if you want to make at least some use of your jack-o-lantern pumpkin so it doesn’t all go to waste once the last trick-or-treater fades into the night, you’ve got two reasonable options. While carving the pumpkin, you can carve out some extra pulp from the inner walls and cook it for use in recipes – this has the added benefit of making the walls thinner and easier to carve. You can also reserve the seeds, which can be cleaned and roasted in the oven. In both cases, make sure you use clean spoons, knives and bowls when hollowing out and carving the pumpkin.
An alternative to carving the pumpkin would be to draw on the exterior of the pumpkin with a food-safe marker instead of hollowing it out and carving it. That way you can make use of the pumpkin afterwards.
It’s also worth noting that some pumpkins are better suited to the task of cooking than others. If you want to cook a pie from scratch, small “sugar” pumpkins are typically preferred to the larger pumpkins used for carving jack-o-lanterns.