We study the optimal foreign exchange (FX) intervention policy in response to a positive terms of trade shock and associated Dutch disease episode in a small open economy model. We find that during a Dutch disease episode tradable production drops below the socially optimal level, resulting in lower welfare under learningby- doing (LBD) externalities. FX reserves accumulation improves welfare by preventing a large appreciation of the real exchange rate and by inducing an efficient reallocation between the tradable and non-tradable sectors. For an empirically plausible parametrization of LBD externalities, the model predicts that in response to a 10 percent increase in commodity prices FX reserves should increase by 1.5 percent of GDP. We also find that the welfare gains from optimally using FX reserves are twice as high as the gains from relying only on monetary policy. These results suggest that FX intervention is a beneficial policy to counteract the loss of competitiveness during a Dutch disease episode.