Recent wide spreading of Ransomware has created new challenges for cybersecurity over large-scale networks. The densely connected networks can exacerbate the spreading and makes the containment and control of the malware more challenging. In this work, we propose an impulse optimal control framework for epidemics over networks. The hybrid nature of discrete-time control policy of continuous-time epidemic dynamics together with the network structure poses a challenging optimal control problem. We leverage the Pontryagin’s minimum principle for impulsive systems to obtain an optimal structure of the controller and use numerical experiments to corroborate our results.