If I hear the word pronounced, I can tell whether it's -ía or -ia based on whether the "i" has its own syllable or not. Likewise, I can look it up in a dictionary. But apart from that, how can I tell if I should use the tilde or not?
An example of a word with the ending of -ía is sangría, which according to Wiktionary has an etymology of "From sangre (“blood”) + -ía".
An example of a word with the ending of -ia is altisonancia, which according to Wiktionary has an etymology of "altisonante + -ia".
Words borrowed from Latin and then Ancient Greek don't seem to be any more consistent. One word with -ía is policía, which is "From Latin politīa, from Ancient Greek πολιτεία (politeía)." One word with -ia is historia which is "Borrowed from Latin historia, from Ancient Greek ἱστορία (historía)."
One piece of useful information I found was that -ería is a common suffix, while there doesn't seem to be a suffix of "-eria". (Are there any words ending with eria?)