As winter settles in and temperatures plunge, people turn to food and drink to provide a little warmth and comfort. In recent years, an unconventional type of warmth has elbowed its way onto more menus: the bite of chili peppers, whether from the red jalapeños of Sriracha sauce, dolloped on tacos or Vietnamese noodles, or from the dried ancho or cayenne peppers that give a bracing kick to Mayan hot chocolate.

But the chili sensation isn’t just warm: It hurts! It is a form of pain and irritation. There’s no obvious biological...