When they're in the stem of the word, it's basically memorisation, like "ee" versus "ea" in English. (Or, as in English, knowing the etymology and history of the word in older stages of the language when they were still pronounced differently is a theoretical possibility.)
In endings, it's usually fixed by the grammar, e.g.
- -η: feminine singular nouns (η πόλη, την πόλη); neuter plural nouns where the singular has -ος (το τείχος, τα τείχη)
- -ι: neuter singular nouns (το αγόρι)
- -οι: masculine plural nouns (οι άνθρωποι), feminine plural nouns (οι οδοί)
- -υ: a few neuter singular nouns (το δόρυ, το άστυ) -- not that many so those can be learned as exceptions from "neuter singular -ee sound is -ι"
- -ει: verb ending (αυτός θέλει, εγώ θα έχω διαβάσει)
Sometimes if the Greek word was borrowed into English, that can be a clue -- οι, η usually turn into "e" while ι becomes "i" and υ becomes "y", e.g. ανάλυση "analysis" must have an upsilon in the third syllable because the English has a "y" there, and κοιμητήριον "cemetery" can't have iotas or upsilons in the first three syllables because English doesn't have an "i" or a "y" there. (The -y in the ending of "cemetery" is an English ending rather than indicating an upsilon in the original; it's not part of the word stem, I'd say.)
We moderators cannot see your sentence therefore before you make a comment you should have made a REPORT. Then post on the comment page.
TIPS TO MAKE LEARNING EASIER + HOW TO REPORT A PROBLEM
And check out the Greek Forum here with more links.