Footnotes 92 and 93 to Rambam Hilchos Terumah 1:22 explain the halacha. Note that the difference is based on what is involved in the completion of the work.
22 When produce from Eretz Yisrael is taken to the Diaspora, it is exempt from the obligations of challah, the terumot, and the tithes,
[for one of the prooftexts requiring the separation of these gifts,
Numbers 15:18]91states: "[the land] to which I am bringing you."
[Implied is that] these obligations exist there alone. In the
Diaspora, one is exempt.92 If [the produce] was taken to
Syria, one is obligated by Rabbinic decree.
Conversely, we are obligated [to separate] challah from produce from
the Diaspora that was brought into Eretz Yisrael, as [suggested by the
phrase] "to which." [Implied is that] one is liable [to make these
gifts] there, whether the produce is from Eretz Yisrael or the
Diaspora. If the obligation [to separate challah or the tithes] was
established [because of the actions] of a Jew after the produce
entered Eretz Yisrael, there is an obligation of Rabbinic origin to
separate the tithes.93
92. The Ra'avad differs and maintains that the exemption
from the obligation to tithe applies only according to Scriptural Law.
According to Rabbinic Law, all authorities agree that one is
obligated, for this produce is comparable to that of Ammon and Moav.
The Radbaz does not accept this perspective, stating that there is no
source which maintains that a Rabbinic obligation exists. The Radbaz
does, however, qualify the Rambam's ruling, explaining that it applies
only when the work that makes the produce obligated to be tithed is
completed in the Diaspora. If this work is completed in Eretz Yisrael,
the obligation to separate the tithes has already been incurred and
they must be separated even if the produce was later taken to the
Diaspora. For this reason, in most instances, terumah and tithes must
be separated from produce that is grown in Eretz Yisrael in the
present age and later exported to the Diaspora. This, however, applies
to fruits only, not vegetables as stated in Chapter 2, Halachah 6.
93. The Kessef Mishneh questions why the obligation to
separate the tithes is only of Rabbinic origin. Since the concept is
based on the exegesis of the same Biblical term as mentioned above, if
the work that made the produce obligated to be tithed was performed in
Eretz Yisrael, why is the obligation not Scriptural in origin? The
Kessef Mishneh answers that since the prooftext mentions "the bread of
the land," one can conclude that the obligation applies only to
produce grown in the Holy Land itself. Alternatively, the Kessef
Mishneh suggests that indeed if the work that makes the produce
obligated to be tithed is completed only in Eretz Yisrael, the
obligation is indeed Scriptural in origin. This ruling is quoted by
the Siftei Cohen 331:22.