The purpose of this paper is to extend the dynamic resource allocation problem by including stock externalities like accumulated CO2 and SO2 emissions as well as flow externalities like waste of energy or pollutants which can be abated (SO2). The objective is to examine how the evolution of energy-, CO2- or SO2-tax rates can address these problems in an optimal way. The concern about the time profile of an energy tax arises from the fact that fossil fuels are an exhaustible resource and that global warming, being a consequence of carbon accumulation in the atmosphere, is a stock externality problem. We use a micro model of a firm, which maximizes profits, uses energy as one of its inputs and is confronted with a varying energy tax. It reacts by substitution, by changing its output level, by investing in energy efficient technology or by purchasing abatement equipment. The government is well aware about firms reaction on price signals. It maximizes a stream of social welfare by choosing an optimal path of its instrument - an energy tax. Our analyses supports the idea of a first rising and later falling tax over time.