It is very difficult to say what the state of the economy is at at a given point in time so it is difficult to create conditions that would serve as an on/off switch for a certain tax.
There are what are called "automatic stabilisers", however, which act in a way similar to what you described.
The marginal income tax is actually an example of an automatic stabiliser. If the economy is doing well as measured by an increase in nominal wages, the proportion of an individuals income that goes to paying off tax will be increased, which slows down economic growth.
On the other side of this, there are welfare payments which function as automatic stabilisers when the economy is not doing so well. People with low income tend to spend a greater proportion of their income than those who have a higher income, so when the economy is doing poorly and unemployment rises, more people get welfare and they spend a large amount of their welfare payments, stimulating the economy.
Depending on who you ask, it may be a bad idea to tax specific sectors as that will distort the market.
Further, it might prove dangerous to spring taxes on people and businesses if the economy is "too good", this could disrupt planning by businesses as their plans may be dependent on a given rate of tax.