I assume you mean humanity or the world. I doubt oil will ever run out. As things become scarcer, they become more expensive. People respond by using less of the commodity.
In the case of oil, people will use less, find alternatives and the higher prices will also make more expensive ways of finding and extracting oil more feasible.
This is the law of supply and demand in action and it will work this way as long as human nature persists.
Of course, there are undesirable impacts of burning oil and these are not addressed by letting the market set the price of oil. In fact, it is possible for oil to be even cheaper in the future if technology advances dramatically, potentially making these negative effects even greater.
But one can use the law of supply and demand to curtail these negative effects as well. If you tax the release of CO2 into the air and then use the proceeds to fund a bounty that rewards technologies that cheaply remove CO2 from the atmosphere, you can create incentives that will move entrepreneurs to innovate. The X Prize is one example of such a bounty paid for innovation, in that case, private space flight was rewarded.
Even a 1% tax on oil would yield billions a year for such incentives. But experience has demonstrated that it takes much less to make people compete for such a prize.
In short, the market will handle shortages but can also be leveraged to minimize harmful effects.