Creosote and humidity
The most common cause. Creosote and soot left in the flue from winter fires react with warm, humid summer air and give off a smoky or tar like smell. The fix is a proper sweep, which removes the source instead of masking it.
Air being pulled down the chimney
Modern homes are tight, and bathroom fans, kitchen hoods and dryers pull air out of the house. That air has to come from somewhere, and often it comes down the chimney, bringing the smell with it. A damper that closes properly, or a top sealing damper, helps a lot.
Water getting into the chimney
A musty or damp smell usually means water. A missing cap, a cracked crown or failed flashing lets rain in, and wet masonry and debris smell. Left alone, the same water does freeze and thaw damage in winter. See chimney leaks after rain.
Animals and debris
Birds and squirrels nest in uncapped chimneys, and leaves collect on the smoke shelf. A strong, unpleasant smell can mean something got in and did not get out. A cap keeps it from happening again.
What fixes it
Usually a chimney sweep and inspection, which is $159, plus a cap or damper fix if the inspection shows one is needed. Air fresheners and baking soda only cover it up.