Yes, there is a way to tell: Look in the dictionary. I'm not trying to be glib. I look in the dictionary all the time to check to see if something is two words or a single compound word. In fact, earlier today I couldn't remember if "more so" was one word like "notwithstanding." It's not, but to be sure, I had to check.
Anyway, there is no set pattern you can fall back on to tell. Even the same word goes many different ways: halftime, half-day, half past. All three refer to time; all three combine "half" differently. Often, the same construction deviates from itself: mid-twenties and late twenties. This makes the phrase "mid- to late twenties" an awkward construction. The long and the short of it is it's without rhyme or reason, so you either have to try and remember it all or keep a dictionary handy—or more likely, both.