Is it appropriate to underline key words in an exam answer?
I do not believe that there is a strong consensus on use of textual emphasis in scientific writing.  In publications, I have often seen people use italics (and done so myself) to designate the first use a word in its definition; I have rarely (but occasionally) seen them used for emphasizing a key phrase.  Typically, in scientific writing one is expected to make the key phrases clear through prose alone---but of course, there are tricks to improve the visibility of key phrases in prose, such as use of lists, position of a phrase within a paragraph, etc.

In an exam, since things are handwritten and there is little chance to revise, I would expect standards to generally be more flexible.  Certainly I personally might find it a bit odd, but not at all problematic, for a student to underline words or phrases.  Your professors may or may not agree with me---as I said, I do not think there is any strong consensus.