David J. Des Marais, a researcher in the Exobiology Branch of the National Aeronautics and Space Administration Ames Research Center, has studied this very question. Here is his response:
"The questioner is a remarkably perceptive individual! He is absolutely correct that an equivalent amount of photosynthetic organic matter must be buried in the earth's crust to account for the free oxygen in the atmosphere. And in fact, there is not nearly enough fossil fuel to account for the atmospheric oxygen inventory. But there is a lot more organic matter buried in the crust in the form of finely disseminated particles incorporated in shales and limestones.
"Organic matter in shales is the dominant reduced carbon reservoir. The earth's crust contains 1.1 x 1021 moles of reduced carbon--that is, carbon that has been freed from its oxygen (one mole of an element is equal to 6.02 x 1023 atoms of that substance). The total amount of organic carbon needed to account for all the oxygen in the atmosphere is only 0.038 x 1021 moles! In other words, based on the amount of buried carbon, the atmosphere seems to contain far too little oxygen. Some of that missing oxygen has gone into other materials, 'oxidizing' them in the process. Oxidized reservoirs whose oxygen probably derives from organic matter are sulfate, found in both seawater and evaporite rocks (equivalent to 0.48 x 1021 moles of organics) and in ferric iron (equivalent to 0.064 x 1021 moles).
"Clearly, there is more organic matter in the crust than can be accounted for only by the amount of oxygen in the air and in these oxidized reservoirs. The additional organic matter must have come from anaerobic bacteria that converted carbon dioxide to organics via processes that do not create free oxygen. (These bacteria use reduced chemical species from weathered igneous rocks and from emanations of volcanic/hydrothermal gases and fluids.)
"Oxygen can also be made by the splitting of water molecules by ultraviolet radiation from the sun, a process called photodissociation. The only way that any free oxygen product can accumulate, however, is if some of the hydrogen that is produced at the same time escapes into space, permanently removing it from the atmosphere. (Otherwise the hydrogen and the oxygen just recombine into water again.) The rate of net oxygen production by ultraviolet photodissociation is equal to the rate at which the hydrogen escapes to space. This rate is so low that this source of free oxygen is trivial compared with the amount of oxygen created by biological activity."