For example for words like in-depth or long-term I would always use a hyphen, and I tend to favor using them in general unless I'm certain there shouldn't be one, but often I find both used for words like this. Can both be correct in different situations? Is there a general rule for when you should or should not use hyphens in compound words?
There is no general rule for the use of hyphens in compound words.
Compound words can be formed by combination of different kinds of words, i.e., noun/noun, adjective/noun, verb/preposition, preposition/noun etc. In any of the cases, there is no rule for hyphenation. One must know if a hyphen is involved in a word or not. For example, the word 'laughing-gas' is often written as 'laughing gas'. Although using hyphens avoids ambiguity it is often not used without posing any trouble. For instance, consider a sentence, 'nitrous oxide is commonly known as laughing gas'. In this sentence, most people would interpret the word 'laughing gas' as one and not as a gas that is laughing. However, it is good if a hyphen is used between the two components of the compound word making it 'laughing-gas'. This would always prove to be helpful.
Some other words like hot dog, takeout, potbelly etc. are widely used without hyphens. Earlier, takeout was usually written as 'take-out' but the hyphen got out of fashion over time but it is absolutely correct to use a hyphen in the word 'take-out'. Both the forms are correct.
Americans tend to avoid the use of hyphens while British like to use hyphens. For example, the oxford dictionary uses 'pot-belly' while the American heritage dictionary uses 'potbelly'.
When two words are joined together as one word without any space in between them, it is called closed form. For example, keyboard, toothbrush, underworld etc.
When two words are brought together to form one word with space between them, then it is called as open form. For example, hot dog, life boat etc.
When two or more words are connected with one or more hyphens in between them then they are said to be in hyphenated form. For example, brother-in-law, runner-up, kilowatt-hour etc.