Use a hyphen when you need to connect two or more words together to avoid confusion or ambiguity.
One common use is to connect two adjectives that modify one noun (the “compound modifier”). For example, it’s “the third-place runner,” “the last-chance offer” and “the best-selling novel.” In these cases, the two words together describe the “runner,” “offer” and “novel.”
How do you determine if a hyphen is needed? One trick is to put the word “and” between the two modifiers. If it makes sense, you don’t need a hyphen. If it does not make sense, use a hyphen. (e.g., The “best-selling novel” is not necessarily the “best” and “selling” novel.)
Another trick: try reversing the order of the modifying words or even eliminating one of them. If the sentence basically retains its original meaning, the words do not need to be connected with a hyphen.
Naturally, this being English, there are exceptions to the rule. Do not use a hyphen if the first word is “very” or if it ends in “ly” (e.g., “the amazingly fast race”).
Why? “Very” and “ly” words are always adverbs. As such, they can only modify a verb, adverb or an adjective, so there is little chance of confusion.