This topic is largely treated in Talmudic books.
We are going to start with a Mishna in Sanhedrin 9, 6
וְהַבּוֹעֵל אֲרַמִּית, קַנָּאִין פּוֹגְעִין בּוֹ .
Or cohabits with a heathen [lit. syrian {Aramean}] woman, he is punished by zealots.
One see that in some circumstances, not treated in this post, man involved in intimate relation with a non-Jewish women is punishable by zealots. If he is punishable, one can assume that he broke the law. So what is the problem for a Jewish man who is involved in intimate relationship with a non-Jewish woman? Bartenura said:
אֲבָל עָנְשׁוֹ מְפֹרָשׁ עַל פִּי נָבִיא, יַכְרֵת ה' לָאִישׁ אֲשֶׁר יַעֲשֶׂנָּה. וּמַלְקִין אוֹתוֹ אַרְבַּע מַלְקֻיּוֹת מִדִּבְרֵי סוֹפְרִים, מִשּׁוּם נִדָּה, מִשּׁוּם שִׁפְחָה מִשּׁוּם נָכְרִית, מִשּׁוּם זוֹנָה
His punishment was spelled out in the book of Malachi (Mal'achi 2, 12): "May the LORD cut off to the man that doeth this", and we punish him by four flagellations for rabbinic prohibitions: Nidda, Slave, Stranger, Prostitute (if he is Cohen),
It's seems not current to find a "Kareth" in Prophet book that is not found in Pentateuch. In Gemara, we see that Amorayim have great difficulties getting a verse for the prohibition. As summarized in the Bartenura, the standing hypothesis is the verse in Mal'achi. The Rabbinical Prohibition entered into force on a Rabbinical Court at time of Chashmonaym. There are four rabbinical prohibitions whose initials are 'נשג"ז' (N.Sh.G.Z.).
We shall proceed to consider Halacha. Firstly Rambam
I will try to select only the parts of the Halacha treating a kind of relationship based on sexual drive only, without any cohabitation contract.
The begining of the 12th chapter of Hilchot Issure Biah.
Look only on bold characters
Halacha 2
The Scriptural prohibition applies only to marital relations. When, by contrast, one engages in relations with a gentile woman with a licentious intent, he is given "stripes for rebellious conduct" according to Rabbinic Law. [This is a] decree,
lest this lead to marriage.
If [a Jew] designates [a gentile woman] for licentious relations, he is liable for relations with a niddah, a maid-servant, a gentile woman, and a licentious woman. If he did not designate her for himself, but instead, [engage in relations with her] spontaneously, he is only liable for relations with a gentile woman. All of these liabilities are Rabbinic in origin.
Halacha 6
... a person who shares intimacy with a gentile woman is considered as if he married a false deity, as the verse states: "engaging in relations with the daughter of a foreign god." And he is called one who "desecrated that which is sacred to God."
Halacha 7
Although this transgression is not punishable by death penalty by the court, it should not be regarded lightly, for it leads to a detriment that has no parallel among all the other forbidden sexual relationships....
Halacha 8
This matter causes one to cling to the gentile nation from whom the Holy One, blessed be He, has separated us, and to turn away from following God and to betray Him.
There's a strong contrast between the lightness of the sin and the severity of consequences. Rambam explains clearly that the problem is the risk for this open relationship to result in a marriage. Each of us is aware of cases. Cases are frequent. This is described as leading to a detriment that has no parallel among forbidden sexual relations. The message is that this is a trap. All intimate relation of this kind lead potentially to assimilation. The Shulchan Aruch E.H., [1](https://judaism.stackexchange.com/questions/71266/which-to-choose-relations-with-a-non-jewish-woman-or-wasting-seed), [2](https://judaism.stackexchange.com/questions/71266/which-to-choose-relations-with-a-non-Jewish-woman-or-wasting-seed) is similar.
The problem of wasting seed.
Gemara Nidda 13a
דא"ר יוחנן: כל המוציא שכבת זרע לבטלה
חייב מיתה,
שנאמר (בראשית ל"ח) וירע בעיני ה' (את) אשר עשה וימת גם אותו.
רבי יצחק ורבי אמי אמרי: כאילו שופך דמים שנאמר (ישעיהו נ"ז) הנחמים באלים תחת כל עץ רענן שוחטי הילדים בנחלים תחת סעיפי הסלעים, אל תקרי שוחטי אלא סוחטי.
רב אסי אמר: כאילו עובד עבודת כוכבים, כתיב הכא תחת כל עץ רענן וכתיב התם (דברים יב) על ההרים הרמים ותחת כל עץ רענן.
A verse was put in evidence, Genesis 38, 10:
וַיֵּ֛רַע בְּעֵינֵ֥י יְהֹוָ֖ה אֲשֶׁ֣ר עָשָׂ֑ה וַיָּ֖מֶת גַּם-אֹתֽוֹ:
And the thing which he did displeased the Lord; therefore he slew him also.
After first reading, I would argue that the problem is Contraception. He opted for marital relations without "reproduction". Chazal explain that he used the method called nowadays "Withdrawal method". This method has two consequences: Avoid insemination, extra-corporeal ejaculation ("on tree and rock").
Contextualization after contextualization
At beginning, Gemara is commenting the sentence of Mishna "Every hand that makes frequent examination in the case of men it ought to be cut off". It is against this background that we must view the sentence of Rabbi Yochanan. Nothing to do with contraception. Rambam Issure Bia 21, 18, HERE
reports this sentence on halachot. And in the next sentence he address an other issue, marrying a prepubescent wife:
It is forbidden to release sperm wastefully. Therefore a person should not enter his wife and ejaculate outside of her. A man should not marry a minor who is not fit to give birth.
Those who, however, release sperm with their hands, beyond the fact that they commit a great transgression...
See
Mesharet Moshe. He said that poskim made a difference between wasting seed and spousing a non-fertile wife: The second is only an annulment of Mitsvat Piria Verivia.
See Rambam. See in Sefer Nishmat Avraham EH 23 in name of R.S.Z. Aurbach that obviously Rambam and Rabenu Tam do not consider this sin as Scriptural, and so there is no Macat Mardut. But Rabbi Moshe Feinstein does not agree and considers it as a Scriptural Sin.
To see the problem as a choice between two averot is perhaps not a real problem. To make a sin can not protect against another (the case in Sefer Chassidim is a rare exception for short term resolution). We can say without missing that a man involved in relations with non Jewish women is more dangerous for future, less prohibited for present.