As oil runs out, the price of gas will rise, discouraging people from using it. For example, gas prices hit $5 in the summer of 2008, people responded by driving less
If price rise will become permanent, people will start switching to alternatives: fuel-efficient or electric cars, public transportation, working closer to home.
We have alternative sources of energy: hydro, nuclear, wind, solar. We do not use them much b/c they are more expensive than oil & gas, or b/c they have their own environmental issues. Once oil prices increase, the alternatives will become more viable in comparison.
We will have ample time to build new energy plants. Oil reserves and production quantities are publicly available (value of oil companies depends on them), so we will know when oil is about to run out.