Good question! The way that the carbon budget stays balanced was a bit of a mystery until recently. The amount of carbon in the atmosphere (and the rate at which it was increasing) was lower than models suggested that it should be, given rates of photosynthesis, respiration, and other carbon releasing processes. Somewhere, there was a "missing carbon sink" that wasn't being accounted for. After many years of debating whether the sink was terrestrial or aquatic, it turned out to be a little of both (which is the conclusion to just about every debate in ecology), although somewhat skewed towards the terrestrial (I think). Forests were sequestering more carbon than had been thought, and so were oceans to some extent (although ocean sequestration relied on a chemical reaction that is in danger of reversing if the water warms up too much). For a thorough account, see this article.
But it sounded like you weren't wondering what the missing sink was so much as how there continues to be enough carbon in the air for plants to photosynthesize (if I'm interpreting your question correctly). Carbon gets back into the air for the most part because of cellular respiration, which all organisms, including plants, do. Net primary productivity takes plant cellular respiration into account, but there are still tons of living things on earth eating plants (and thus taking in their carbon) and then breathing it back out after they break down the carbon-containing molecules for energy. There is also natural combustion and volcanoes and such putting carbon back into the air.
EDIT (to address the new part of your question): Oil and coal were produced when large quantities of carbon were buried deep under ground (and thus subjected to lots of pressure) for thousands of years. This is suspected to have happened during the aptly name Carboniferous era, which featured giant plants and, scientists hypothesize, no decomposers to break them down. Since we have much decomposers now, and much smaller plants, oil and carbon are not currently being produced. This is why we call them non-renewable resources. By extracting them from the ground and burning them, we are taken carbon that had effectively been removed from the pool of actively cycling carbon and adding it back in.
The carbon cycle doesn't really have input or output (except the occasional carbon exchange with outer space), because it is defined as already including standing sinks like oil and coal. When we take carbon out of a sink, like oil or coal, it needs to go somewhere else. Terrestrial and aquatic sinks can store some of the additional carbon that we're adding to the not-underground part of the cycle. However, they can't store all of it, so some is staying in the atmosphere instead.