This paper considers a mathematical model of infectious disease of SIS type. We will analyze the problem of minimizing the cost of diseases trough medical treatment. Mathematical modeling of this process leads to an optimal control problem with a finite horizon. The necessary conditions for optimality are given. Using the optimality conditions we prove the existence, uniqueness and stability of the steady state for a differential equations system.