-"tu" is informal: we use it with friends, with people we know or with people who have more or less our age.
In this case, we use the 2nd person singular.
An example can be: "ciao, (tu) come stai?"
-"lei" is formal: we use it with people we don't know, people older than us or with professionals (doctors etc). The sentence here is at the 3rd person singular. Using the same sentence as before we will say: "buongiorno, (lei) come sta?". Here we need to change the greeting as well, since "ciao" is informal. We will choose somenthing more formal among "buongiorno"/"buonasera" or "salve" depending on the part of the day.