Short answer - in a lot of the cases you can’t…
But there are ways to guess with a very high probability.
- if there are several kanji together they are most likely a kanji compound and use the default “ON” reading. Example 漢字 (kan+ji)
- if there is furigana at the end - they use the corresponding “KUN” reading. Example: 食べる (ta.beru)
With just this rule you will be able to guess the reading in ~95% of the cases.
Also, as you learn more and more words you will get a feel for what is the most likely reading in each particular case and will easily be able to guess the reading even for completely new words that don’t even follow the standard rules. Though, you will still encounter exceptions which don’t follow any logic what so ever and in those cases there’s no other way but to just learn them individually (e.g. 海老, which you’d think is read as かいろう, but it’s えび).