One is not judged by the 613 commandments unless one is born Jewish or formally converts. A non-Jew could feel they have a Jewish soul, but may eat pork aplenty until converting. (In fact, non-Jews are not supposed to observe the Sabbath, which leads to some discussion about whether someone studying for conversion should somehow break his Sabbath observance for five minutes!)
As for whether it's included in the Seven Noahide commandments -- there's discussion about it, like there is about everything else -- but the simple answer is no, it's not on that list, and therefore it's not something to be concerned about. (See R' Aharon Lichtenstein's book on the Noahide Laws.)
Rabbi Moshe Feinstein OC4:116 (top of p. 208) writes that there is "no prohibition whatsoever" for Noahides (lo ne'esar klal), and that the story of Er and Onan was God meting out harsh justice for whatever reasons were appropriate at that particular episode (that particular story was rather complicated!), not the standard textbook punishment.
Rabbi Mendel Senderovic's Atzei Besamim EH#19 cites Rabbi Feinstein, and points to responsum Chavos Yair 108 and Tosfos Sanhedrin 59b in support of this position as well. (Yes, he also cites other opinions, but is inclined in this direction in his final conclusion.)
It is important to note that some language you'll find on this subject ("GREATEST SIN EVER!!! MURDER!!! NO REPENTANCE EVER!!!") is acknowledged (see for example the Feinstein responsum above) by poskim -- experts on the entire canon of Halacha who deal with lots of real-life questions across the board, not Internet pundits laser-focused on one subject -- as exaggeration, so please take what you read with a grain of salt.