The coronavirus disease 2019 (COVID-19) pandemic has had great influence on global health, societies and, economies. In this paper, we propose an optimal control model with contact restrictions, aiming to adopt minimization of infections and economic losses simultaneously. Taking a social contact restriction as the control variable, we establish a control system of COVID-19 with nucleic acid testing and contacts tracking. A bi-objective optimal control problem is proposed, in which the accumulated number of infected individuals and economic losses are involved. Numerical simulations for different weight combinations of objectives are carried out using official epidemic data in Shanghai. From the numerical results, we conclude that effects of the control constriction policies decrease with weight of economic losses increasing; there is a trade-off between the epidemic size and the economic loss, and thus decision-makers may choose the appropriate schemes to implement. Therefore, this work may contribute to analyzing contact restriction strategies to balance epidemic size and economic losses.