Solid candy
TSA’s entry says “Solid food items (not liquids or gels) can be transported in either your carry-on or checked bags.” Hard candy, gummies, lollipops and candy canes are solid. TSA doesn’t have a separate entry for any of them.
Liquid and gel candy
The same entry says liquid or gel food over 3.4 ounces isn’t allowed in a carry-on. TSA’s travel tips give the test: “If you can spill it, spread it, spray it, pump it or pour it, and it’s larger than 3.4 ounces, it should go in a checked bag.” A bottle of candy syrup fails it. A bag of jelly beans doesn’t.
At the checkpoint
TSA’s note on the entry: officers “may instruct travelers to separate items from carry-on bags such as foods, powders, and any materials that can clutter bags and obstruct clear images on the X-ray machine.”
In a stocking or a gift box
TSA encourages gift bags or boxes with lids that come off, so an officer can look inside “and avoid the possibility of opening fully wrapped presents.” A box of candy canes with the lid loose does that. More in food gifts and wrapped gifts.
Flying home from abroad
TSA’s answer covers screening at US airports. On the way home you go through the other airport’s screening first, and its rules are the ones that count there.
Coming home through US customs
CBP’s agriculture page and its page on prohibited items don’t name candy or sweets, and neither does USDA’s page for travelers. With no named rule, the call belongs to the CBP agriculture specialist at the border.
Declare it either way. USDA says declared food brings no penalty, even when it’s refused. What happens if you don’t.

TSA puts this on every entry: “The final decision rests with the TSA officer on whether an item is allowed through the checkpoint.”