Computer viruses can cause significant damage to computer systems, and that damage can lead to loss of data and financial losses for computer users. To deal with computer viruses and to avoid them in the future, system can be updated and better antivirus software installed. Someone experts can remove viruses without antivirus software and fix infected computers that have serious and great damage. In this paper, we consider three types of control to deal with infected systems and preventing further spread of viruses: the installation of antivirus software on infected computers, the installation of antivirus software on susceptible computers, and the cleaning and repairing of infected computers without the use of antivirus software. We proposed a model that had three equilibrium points: two virus-free and one endemic. Pontryagin’s maximum principle was used to solve the problem of optimal control in our model. Some numerical simulations showed that an acceleration in the declining number of infected computers can be achieved by giving control factors on susceptible and infected computers. Furthermore, an increase in relative weights will result in fewer control factors and vice versa.