Chronic viral diseases such as human immunodeficiency virus (HIV) and hepatitis B virus (HBV) afflict millions of people worldwide. A key public health challenge in managing such diseases is identifying infected, asymptomatic individuals so that they can receive antiviral treatment. Such treatment can benefit both the treated individual (by improving quality and length of life) and the population as a whole (through reduced transmission). We develop a compartmental model of a chronic, treatable infectious disease and use it to evaluate the cost and effectiveness of different levels of screening and contact tracing. We show that: (1) the optimal strategy is to get infected individuals into treatment at the maximal rate until the incremental health benefits balance the incremental cost of controlling the disease; (2) as one reduces the disease prevalence by moving people into treatment (which decreases the chance that they will infect others), one should increase the level of contact tracing to compensate for the decreased effectiveness of screening; (3) as the disease becomes less prevalent, it is optimal to spend more per case identified; and (4) the relative mix of screening and contact tracing at any level of disease prevalence is such that the marginal efficiency of contact tracing (cost per infected person found) equals that of screening if possible (e.g., when capacity limitations are not binding). We also show how to determine the cost-effective equilibrium level of disease prevalence (among untreated individuals), and we develop an approximation of the path of the optimal prevalence over time. Using this, one can obtain a close approximation of the optimal solution without having to solve an optimal control problem. We apply our methods to an example of hepatitis B virus.