I don't believe there's a rule to know when to pronounce "X" as "ks" or "j." So you're just going to have to memorize the words with their corresponding pronunciaton. Nothing personal but it's payback time. Now, you're going to experience what it's like for Spanish-speaking people to learn how to pronounce your language.
P.S. When speaking Spanish, never pronounce "Texas" as "Teksas."