This depends on what kind of incense you're burning and the ingredients used to make it. Dipped incense (think of those sticks you see for sale at your local head shop that come in scents ranging from Sandalwood to to Wild Berry to Bubblegum) are often filled with synthetic ingredients that many people find unpleasant and headache inducing. Dipped incense in contrast to ‘hand-rolled' is what is usually mass-marketed and found everywhere from the vape shop to Walgreens.
Before Purchasing Incense Check to See if its Made with Charcoal or Fragrance Oils.
Dipped incense sticks are made by purchasing unscented incense sticks in bulk, these blanks are usually made of bamboo but often contain other ingredients as filler like sawdust. Then the blank sticks are dipped into fragrance oil or essential oil. Fragrance oils are often made from synthetic compounds making them easy to manufacture at high volume and much less expensive than essential oils. Burning synthetic compounds is not a safe bet if you're worried about your health, if you see incense sticks that don't say they are 100% organic or made with essential oils you might want to hold your breath.
Some incense cone pyres are made from pre-purchased cones that can contain charcoal or burning accelerants so that the incense cone burns longer. Charcoal is toxic when burned and breathed in.
Here's the Good News:
Alternatives to the dipping process include hand-rolled incense or Japanese mold-made incense. Hand rolling incense generally produces a product of much higher quality than the dipped version because it uses high quality whole plant ingredients. Traditional Japanese incense making involves using natural ingredients like tree resins and herbs that get mixed together, then formed and dried. There is a wide variety of quality in incense so one needs to know what they are buying. If you want a healthier incense to burn for relaxing or meditating find out how it was made before taking a whiff.
Incense as Medicine:
Most of the ingredients used in natural incense are materials with long established conventional uses as medicines, food flavorings, and self care. If these materials were unsafe for consumption, they wouldn't be used so widely in ayurvedic, Traditional Chinese Medicine and Shamanic traditions.