Are you asking when it is better to use formal or informal? Or how to differentiate between the two?
It's really vague to differentiate the two because it really depends on the sentence but usually, formal sentences end in "요".
If you're asking when to use them, formal korean is usually used when addressing people who:
1. are older than you
2. have superiority over you (teacher, boss, etc)
3. people you just met and don't know very well.
Just use it whenever you have to be polite.
Informal is used when:
1. you're talking to people younger than you
2. You're close with
Notice that you don't always use informalities even if you have superiority over someone. In some cases you can, but in settings like offices, even if you are the boss, its always good to be polite to those underneath you so sometimes you'll see bosses talking to their workers in formal tones.