When two words are used together like a single adjective before a noun they are termed compound modifiers and should be separated by a hyphen. For example,
They usually looked for a child-friendly restaurant.
She was a well-known teacher.
18th-century artist
Five-year contract
Be aware though that there is no need for a hyphen when the compound modifier comes after the noun. For example,
The restaurant was child friendly.
The teacher was well known.
The friends gathered for a house party which was the last time they ever got together.
The friends gathered for a house party; it was the last time they ever got together.
Conventionally, adverbs ending in -ly (e.g. highly regarded) are not hyphenated. Also, compound modifiers that have become words in their own right (e.g. semiconscious.) are not hyphenated.
Knowing whether to use a hyphen is not always obvious. Some compound words are hyphenated (e.g. all-inclusive), some are separated by a space (e.g. school bus), and some joined together (e.g. midlife). There are some rules (with exceptions!) and guidelines, but sometimes a check for the word in a dictionary is required. A handy rule is that, if in doubt, leave it out!
A good question to ask when determining whether to use a hyphen is will there might be any confusion in meaning if the hyphen were not used. For example,
He came from a little known town.
He came from a little-known town.
The first example could mean the town was little and also well known. The second one is unambiguous and means the town was not well known.