First, we have to remember that externalities come in two basic types. There are both positive and negative externalities. Of course, the government will respond differently to the two.
With regard to positive externalities, the government typically subsidizes actions that cause them. The clearest example of this is schooling. The government promotes schooling by providing free public schools. This allows more people to get educated, which causes the positive externalities the government wants.
With regard to negative externalities, there are a number of things that the government can do. It can simply ban a type of action that is believed to have negative externalities. Bans on things like drug use and prostitution are motivated in part by a desire to prevent the negative externalities that they bring along with them. The government can take less drastic actions as well. It can impose extra taxes on activities that lead to externalities. It can regulate those activities so that less of the externality will occur. All of these are ways in which the government tries to reduce the negative externalities that come with various types of economic activity.