Answer to your general question:
It is not informal to use "wh-words" like what, who, how, which, where in non-question sentences. These words have a number of other uses that are valid at all levels of formality. (For example, who is used as a relative pronoun in a phrase like "the person who helped me".) But you need to learn how to use them correctly.
Answers to your questions about specific sentences:
It is not grammatical to say "the oversupply and overconsumption of diesel than what is socially optimal". One problem is that the presence of the nouns "oversupply" and "overconsumption" does not warrant the use of the word "than". The word "than" is used with a preceding adjective, as in the expressions "higher than" or "greater than". An alternative wording of the sentence could be
We are dealing with a case of a negative externality of consumption, which results in oversupply and greater consumption of diesel than is socially optimal.
The other sentence is grammatical as it is, but I would agree with Jesper's suggestion to change "revolution in how" to "revolution in the way". The Google Ngram Viewer indicates that the second wording is more common: