For some states, cheap oil isn't such a good thing

The recent drop in oil prices is providing relief to consumers' budgets in the form of lower gasoline prices.

But if you happen to live in a region that's a big energy producer, falling oil prices may soon take a bite out of your state's budget.

Read MoreCrude to 'go the way of whale oil': Dennis Gartman

An oil refinery in Kenai, Alaska.
Farah Nosh | Getty Images
An oil refinery in Kenai, Alaska.

Take Alaska. The state, which relies on oil taxes to fund most of its operating budget, is facing the biggest risk of a shortfall, according to Moody's Investors Service.

The drop in oil prices is all the more painful for states that were expecting prices to go higher, said Moody's analyst John Lombard.

Read MoreBillionaire oilman: I'm not cutting production ... yet

"Alaska and New Mexico both forecast higher oil prices for their (latest) fiscal years and may need to make budgetary adjustments," he said.

Of the five states with budgets that rely on oil and gas revenues, Texas is the largest producer with 3.1 million barrels per day of production in July. But that revenue accounts for only 8 percent of the overall budget, compared with 89 percent in Alaska's, according to Moody's.

Texas budget officials also did a better job predicting where oil prices were headed when they forecast how much tax they'd collect, pegging the benchmark price this year at $82.18 per barrel, roughly where oil has traded recently. For next year, Texas budget analysts assume oil prices will average $80.33 per barrel.

Alaska officials were much more optimistic, counting on oil prices to hit $106.61 this year and $105.06 in 2015.

Read MoreWhy OPEC is losing its ability to set oil prices

North Dakota, the second-largest producer behind Texas at 1.1 million barrels per day, counts on oil and gas for 6 percent of its revenue. Officials there were even more conservative, basing their budget projections on oil prices at $75 per barrel this year and $80 in 2015.

New Mexico counts on oil and gas revenue for 19 percent of its budget, Moody's said, while Oklahoma relies on oil and gas tax revenue for 4 percent of its spending

Lower oil prices over an extended period could derail efforts to explore and drill new wells in Alaska and could squeeze profit margins for high-cost "tight" oil deposits that have helped spur the recent boom in U.S. energy production. Some of those drilling operations would no longer pay for themselves if oil falls below $80 per barrel.

The budget shortfalls don't pose an imminent threat, Moody's said, because oil-producing states used the recent run-up in oil prices to build up a cash cushion. Despite its heavy reliance on oil taxes, Alaska has set aside $26 billion in reserves, more than three times its 2013 operating revenues, Lombardi said.

Other states with big reserves include North Dakota, with $2.5 billion, or 78 percent of revenues. Texas has set aside $8 billion, or 16 percent of revenues, while New Mexico's has reserves of $671 million, or 12 percent of revenues.