Subsidies are commonly used to encourage behaviors that can lead to short- or long-term benefits. Typical examples include subsidized job training programs and provisions of preventive health products, in which both behavioral responses and associated gains can exhibit heterogeneity. This study uses the marginal treatment effect (MTE) framework to study personalized assignments of subsidies based on individual characteristics. First, we derive the optimality condition for a welfare-maximizing subsidy rule by showing that the welfare can be represented as a function of the MTE. Next, we show that subsidies generally result in better welfare than directly mandating the encouraged behavior because subsidy rules implicitly target individuals through unobserved heterogeneity in the behavioral response. When there is positive selection, that is, when individuals with higher returns are more likely to select the encouraged behavior, the optimal subsidy rule achieves the first-best welfare, which is the optimal welfare if a policy-maker can observe individuals’ private information. We then provide methods to (partially) identify the optimal subsidy rule when the MTE is identified and unidentified. Particularly, positive selection allows for the point identification of the optimal subsidy rule even when the MTE curve is not. As an empirical application, we study the optimal wage subsidy using the experimental data from the Jordan New Opportunities for Women pilot study.