We study optimal monetary and exchange rate policy in a small open economy facing oil price shocks. In a model with segmented financial markets that generate endogenous UIP deviations, the first-best allocation is achieved through a combination of interest rate policy and foreign exchange intervention (FXI). Monetary policy stabilizes domestic inflation and the output gap, while FXI targets the UIP wedge to offset financial frictions. Oil price shocks endogenously move the net foreign asset position, giving rise to financial imbalances that make FXI essential—a mechanism distinct from exogenous financial shocks highlighted in the literature. Quantitatively, for a calibrated oil exporter, suboptimal regimes such as a free float or a simple peg entail sizable welfare losses of around 2% in consumption-equivalent terms, though peg, and especially peg with fuel subsidies, can outperform free floats. Overall, FXI is crucial to break the destabilizing link between real commodity shocks and financial risk premia.