Malware is a malicious software which aims to disrupt computer operations, gather sensitive information, and gain access to private computer systems. It can induce various sorts of damage, including economic costs, the leakage of private information, and instability of physical systems, etc. The distribution of antivirus patches in a network enables the control of the proliferation of malicious software and decreases possible losses. Multiple types of malware can coexist in a network. Hence it is important to protect a computer network from several heterogeneous malware, which can propagate in the network at the same time. In this study, we model the propagation of two types of malware using a modified two-virus epidemic model. We formulate an optimal control problem that seeks to minimize the total system cost that includes the economic value of security risks and resources required by countermeasures. We introduce an impulse control problem to provide efficient control of the epidemic model compared with its continuous control counterpart. Numerical experiments are used to corroborate the results.