WHENEVER the federal government needs more money -- as it now does, most assuredly -- the subject of energy taxes comes up. It can be a very good idea if it's done carefully. But doing it carefully is crucial. The world has painfully learned over the past dozen years about the influence of energy prices.

The subject usually comes up when a tax on imported oil is proposed. It's an idea with a lot of appeal at first glance. Tariffs usually have a lot of appeal at first glance. But an oil tariff is no different from any other tariff. The price of the imports sets the price for the domestic product. Currently this country imports about a third of its oil. It means that for every dollar collected by the federal government in the tax, $2 will go to the domestic oil industry in higher pces. Is that good tax policy?

There are a couple of points in its favor -- but neither has much to do with tax policy. The oil industry will point out that higher prices mean larger incentives to find new domestic reserves and reduce dependence on imports. But oil discovery has not proved very responsive to price incentives. This country is producing slightly less oil today than in 1973, when prices began to shoot upward. Another reason to stabilize the domestic price of oil at a higher level might be that a falling price has ominous implications for some of the banks that have lent heavily to oil producers. But that's a fearfully expensive way to rescue banks.

Using a tax to hold the American price of industrial fuels higher than world level puts all of the manufacturers who use oil at a disadvantage in relation to their foreign competitors. And there's more to it than economics. The rise in oil prices created great hardships among some of the people, not all of them wealthy, who heat their homes with oil.

But there's a way to tax energy -- one form of energy -- with none of these unpleasant and costly side effects. Why not tax gasoline? Each penny on a gas tax brings in a billion dollars a year. A 20-cent tax would leave the price of gasoline lower than it was in 1981 and, while nobody liked that 1981 price very much, everyone survived it. And speaking of reducing dependence on imports, it would exert a gentle pressure on car buyers to choose efficient cars. There's been some backsliding recently in that area, and the country has good reason not to let the trend back to big cars go any further.