When the letter /X/ is in a word it is USUALLY pronounced in one of two ways:

  1.  If the /X/ is between a vowel and consonant sound then it is usually pronounced as /KS/
  2.  If the /X/ is between two vowel sounds then it is usually pronounced as /GZ/

Of course, there is always an exception to every pronunciation rule in English.  If the letter X is at the beginning of a word, then it is sometimes pronounced Z.

Examples:

X pronounced KS:  excel, except, extermination, sixth

X pronounced as GZ:  exact, exam, exoneration

X pronounced as Z:  xylophone