Starfurie explained the system reasonably well, I think, but I'll go
into a bit more detail of what I understand. (A native speaker would
do much better at this, but fools go where angels etc)
The first thing you have to understand is that two people in a conversation
have some social standing relative to each other, and this is going to be
reflected in the titles. This has nothing to do with formality; there are
formal and informal ways to express the hierarchy.
-san: A general term of respect like Mr./Ms./Mrs./Miss. Placed at the end
of the family name.
This is used for someone at the same level or slightly higher. I think
secretaries would use it for their boss, for example.
-sama: A more formal version of -san. Denotes more respect.
This is not more formal. Sama is only for people at a higher level than you.
I believe (someone coreect me, please) that it's about as formal as san. I've
always mentally translated it as "lord" or "sir", which is arguably going too
far, but it gives an idea...
o-: Another term of respect, used at the beginning of nouns. Can be used
with -san or -sama.
[You can therefore refer to me as o-StarFurie-sama. NOT!]
I've never seen this that I can remember. I usually see o- attached to
inanimate objects or verbs.
-kun: Term used for boys.
-kun is used for someone who is at the same level as you are, but is more
informal than -san. In modern Japan it is also used to address girls. I think
you can also use it for someone on a lower level, but I'm not sure.
-chan: Term used for, and overused by, girls. This can also note someone
you like.
-chan is used for someone lower than you, in a cute sort of way. That is, you
would use it for little kids, girlfriends, etc. It's not usually used for
boyfriends, but the little kid usage is used for boys.
-sempai: Upperclassmen. Also used in work for senior employees of same rank
or bosses.
-sensei: Teacher. Can also be used for any person in a position of high
authority or respect.
-sensei also means doctor.
Gavin