This paper analyses optimal taxation of foreign profits using a model with heterogeneous multinational firms that serve a foreign market through exports or foreign direct investment (FDI). If a firm switches from exporting to FDI, domestic activity and tax payments may decrease, stay constant or even rise because of intra-firm trade. It turns out that, in contrast to recent claims, in all three cases, the optimal tax system implies full taxation after deduction of foreign tax payments. If the country accounts for the effects of its policy on the foreign price level, the case for taxing foreign income becomes even stronger. However, the globally optimal tax system may require exemption of foreign income from tax.