When observably heterogeneous firms engage in R&D and policy can be conditioned on the heterogeneity, what is the optimal policy? This paper starts with a static duopoly model of R&D competition with uncertainty and finds it welfare enhancing to subsidize the larger firms with no subsidies for the smaller firm, extending existing results. This result follows because the policymaker’s goal is to minimize the average cost of production. Our paper demonstrates that these results are not robust to a dynamic setting. The optimal policy depends on the equilibrium type of competition that emerges without intervention—an insight that cannot be found in a static setting. In a dynamic setting, the degree of competition becomes an endogenous variable. Interestingly, although the optimal policy in some cases provides a slightly larger subsidy for the larger firm, it is the smaller firm that benefits most in terms of firm value.