If you have filled up your gas tank recently, the price of this vital fuel probably left you feeling like you had a big hole in your wallet. The price increases have been so large that they are helping to drive inflation to historically high levels.

Before you throw in the towel and stop driving, consider investing in oil giants like Chevron (CVX 0.75%) and ConocoPhillips (COP -0.41%), so you can actually see some benefit from the high gas prices that are pinching your finances.

1. Big and diversified

While inflation is running hot today, at least partly driven by high oil prices, it is important to take a historical view of things. Oil and natural gas are commodities that are prone to swift and often dramatic price swings. In fact, it wasn't too long ago that a pandemic-driven demand decline led oil prices to painful lows that pushed a number of small producers into bankruptcy court. So if you are a conservative investor, you'll want to own an oil company that can benefit from high prices, survive low ones, and keep rewarding investors along the way. One of the best options is Chevron.

Chevron is a global integrated energy giant with operations that span from the oil field to the gas pump. That helps to smooth out its performance over time, even though it doesn't fully insulate the company from commodity swings. On top of this vertical integration, Chevron just happens to have one of the strongest balance sheets in the industry, with a debt-to-equity ratio of just 0.20. That gives the company plenty of financial wherewithal to handle industry downturns.

But its biggest claim to fame is probably the 35 years of annual dividend increases it has amassed, making it a Dividend Aristocrat. Achieving a record like that in an industry known for volatility is pretty impressive. The dividend yield was 3.8% at Thursday's close, and the stock is likely to move along with oil prices. So if you think oil prices are likely to stay high, this could be a good option for you. Given its dividend history and financial strength, it is also likely to hold up relatively well if oil prices start to fall, just in case you want to hedge your bet. Either way, the dividend looks pretty secure.

2. Going all-in

At the other end of the spectrum is ConocoPhillips, which is exclusively focused on oil and natural gas production. The business' performance will rise and fall right along with the price of oil since there's no other business, like refining or chemicals, to help blunt the inherent commodity volatility here. That's probably not a great approach for conservative investors, but more aggressive ones who think oil prices are set to remain higher for longer or perhaps go even higher might want to take a closer look.

One of the most notable features of ConocoPhillips' business model is the way in which it returns cash to investors. There's a base dividend, which is currently $0.46 per share per quarter. Based on recent stock prices, that amounts to a dividend yield of roughly 1.9%. But the company also recently announced a variable dividend of $0.70 per share. The variable dividend is exactly what it sounds like -- variable. So it goes up and down along with the company's financial results. If energy prices are high, ConocoPhillips will pass along more income. When energy prices are low, the variable dividend will be the first casualty. 

So, in some ways, the return here is leveraged to one of the key drivers of today's inflation. If you think oil prices are set to remain high, this would be a more aggressive way to play the theme.

This, too, shall pass

Inflation won't remain elevated forever, but there's still no easy way to determine just how long the current high rates will last. If you are looking for a way to insulate your investments from the ravages of rising prices, adding a name like Chevron or ConocoPhillips to your portfolio could be a good call. Chevron is the less risky of the two, given its proven ability to weather the ups and downs of the industry while continuing to support its generous dividend. ConocoPhillips' variable dividend policy means high energy prices will flow through as higher dividends for investors.