Most studies of optimal monetary policy under learning rely on optimality conditions derived for the case when agents have rational expectations. In this paper, we derive optimal monetary policy in an economy where the Central Bank knows, and makes active use of, the learning algorithm agents follow in forming their expectations. In this setup, monetary policy can influence future expectations through its e ect on learning dynamics, introducing an additional tradeo between inflation and output gap stabilization. Specifically, the optimal interest rate rule reacts more aggressively to out-of-equilibrium inflation expectations and noisy cost-push shocks than would be optimal under rational expectations: the Central Bank exploits its ability to "drive" future expectations closer to equilibrium. This optimal policy closely resembles optimal policy when the Central Bank can commit and agents have rational expectations. Monetary policy should be more aggressive in containing inflationary expectations when private agents pay more attention to recent data. In particular, when beliefs are updated according to recursive least squares, the optimal policy is time-varying: after a structural break the Central Bank should be more aggressive and relax the degree of aggressiveness in subsequent periods. The policy recommendation is robust: under our policy the welfare loss if the private sector actually has rational expectations is much smaller than if the Central Bank mistakenly assumes rational expectations whereas in fact agents are learning.