If the oil becomes stranded on a beach, the oxygen can only penetrate from the atmosphere. Since the microorganisms consume oxygen when they biodegrade the chemical, for example:
 
C20H42 + 30.5 O2 = 20 CO2 + 21 H2O
 
The oxygen will rapidly be consumed if the bacteria are able to degrade the compound.* The air may not be able to reach the oil that is buried in the sediment because the sediment is waterlogged. The solubility of O2 in water is low.  O2 will be provided by the air but not very quickly if the sediments are saturated with water like on a beach.