There are no hard rules that I've observed, really. As with most things in Japanese, it's context, context, context. The wikipedia article on honorifics actually seems to be pretty good. I'll have to look into it a bit more.