We present an age-stratified SEIR-type model of the Norwegian population, which is extended to include the effects of broad types of Non-Pharmaceutical Interventions (NPIs) like general lockdownpolicies, contact tracing and quarantine and border control. The model can be used to explore the spread of a new virus with given virulence and transmissibility, and to assess the main costs of the disease and the NPIs in terms of lost health and welfare as well as economic losses. We define the optimal strategy as the intervention policy which minimizes the total costs from the pandemic, including health, economic and other welfare effects. We find that the optimal policy typically is a bang-bang-strategy, where costly interventions are either so strict that the pandemic is suppressed to a low level, or they are not used at all. Strict interventions may be used to stop the disease at the herd immunity level (i.e prevent pandemic overshoot), while mitigation policies aimed at merely slowing the spread of the pandemic are not optimal in our baseline simulations. We explore how the optimal strategy depends on the properties of the virus, healthcare capacity, intervention costs, population behavior and other relevant variables. These results are informative for decisions regarding costly investments and interventions. In addition, we explore the consequences of policy errors and delays, providing guidance for decision making in the uncertain early stages of a new pandemic.