When you are sick with a cold or the flu, what chemical is causing body pain, and where in the body does the chemical come from?

Complicated. Some of the pain is a result of the inflammation induce by the infection through the release of cytokines (chemicals released by cells which influence the behavior of other cells). Some pain may also be a result of the death of muscle cells by apoptosis induced by invasion of the virus. There may also be microhemorrhages into tissues creating pain.