Whenever you discuss the formation of compound words, hyphenation rules are somewhere in the mix. Anyone familiar with hyphenation rules knows they can be a headache since there is no definitive set of rules regarding hyphenation and the formation of compound words. So knowing whether to hyphenate a compound, combine the two elements into one, or keep them separate can be tricky. I know from my own experience and because I have seen so many inappropriately hyphenated words in client manuscripts. Consulting the appropriate style manual for the industry you write for may at least provide a guideline. However, if you don't have one available or are not sure which one you need, keep the following guidelines in mind.
Permanent compounds are so frequently used that they have been accepted into the general vocabulary. Compound words such as prime minister, headache, high school, city-state, and others are examples of permanent compounds. Many are so common that most writers will know whether to hyphenate them, separate them, or combine them into one word. If there is any question about how to spell them, you can find them in an online or up-to-date print dictionary.
The area where I see fellow writers struggle most is formation of temporary compounds. A temporary compound is a combination created for a specific purpose. Many of these temporary compounds serve as adjectives or adverbs called compound modifiers, adjectival or adverbial phrases of two or more words. When a compound modifier appears before the noun, the compound modifier is often hyphenated to prevent misunderstanding, like much-needed clothing. Hyphenating the the compound modifier in this phrase clarifies that the clothing is needed badly, rather than abundant but also needed. However, if the compound modifier appears after the the noun, do not hyphenate (the clothing was much needed).
Hyphenation is not usually used for adverb-adjective compound modifiers when ambiguity regarding meaning is not possible. For instance, with the phrase wholly owned subsidiary, confusion as to its meaning is unlikely since wholly clearly modifies the adjective owned and not the noun subsidiary. Note: A compound modifier with an -ly adverb should always be left open.
Ultimately, the best way to assure correct hyphenation when forming compound words is to consult your industry style guide since they have rules for various combinations (adjective-participle, noun-noun, etc.) and exceptions with certain terms. However, if that's not possible, use the above guidelines and you'll be right most of the time.