The objective of this study is to determine the allocation of resources within a multi-site needle exchange program (NEP) that achieves the largest possible reduction in new HIV infections at minimum cost. We present a model that relates the number of injection drug user (IDU) clients and the number of syringes exchanged per client to both the costs of the NEP and the expected reduction in HIV infections per unit time. We show that cost-effective allocation within a multi-site NEP requires that sites be located where the density of IDUs is highest, and that the number of syringes exchanged per client be equal across sites. We apply these optimal allocation rules to a specific multi-site needle exchange program, Prevention Point Philadelphia (PPP). This NEP, we find, needs to add 2 or 3 new sites in neighborhoods with the highest density of IDU AIDS cases, and to increase its total IDU client base by about 28%, from approximately 6400 to 8200 IDU clients. The case-study NEP also needs to increase its hours of operation at two existing sites, where the number of needles distributed per client is currently sub-optimal, by 50%. At the optimal allocation, the estimated cost per case of HIV averted would be dollar 2800 (range dollar 2300-dollar 4200). Such a favorable cost-effectiveness ratio derives primarily from PPP's low marginal costs per distributed needle.