(I'm in a mellow mood - plus one benefit from MathOverflow is that I have gotten a few emails from people "out of the blue" that I wouldn't have gotten otherwise - so I'll have a shot at answering.)
When the question really is about their work. It's very easy to ask a question that isn't about their actual work - for example, if there's a bit that you don't understand then it might be a core bit of the work (in which case, it's okay to send the email) but your confusion might be based on a misunderstanding of something more basic (in which case, don't). To figure out the difference (as that's not always easy), ask someone nearby (ie someone in your university who is therefore paid for answering your questions, allegedly) who's in a similar area. If they can answer your question, great. If not, send the email.
The situation is slightly different if the question arises from some lectures. Unless they are very specialised lectures, it is unlikely to be directly related to the person's work.
Same as any other email would be. Explain how the question arose (you were reading their work - flattery will get you a long way), what the question is, then explain what your background is so that they will know how best to frame their answer. Also, try to make it possible for them to answer your question with the minimum effort possible. Remember: you are asking someone to help you who isn't paid to do it. They will probably want to help you, but make it easy on them. So "can you give me some references where I could find out more" is better than "can you tell me more". The first still allows the person to give more details if they feel so inclined, but also shows that you recognise that it is a bit of an imposition to ask.
Very. But remember that many email programs truncate the subject line (often hilariously) so: "Question about arXiv:0822.2225" or something like that.
Absolutely! I would view this as already being "on the inside" so I'm more inclined to help, and it tells the person a bit about your background so they know what to assume or not to assume in their reply.
Absolutely. Profs are human too (so I'm told). "Thank you for your help" can make someone's day.
Not actually a professor, but I'll answer anyway! No, such emails are not a waste of my time. I'll admit that I don't tend to get many from undergraduates from other institutions, but I do get a few from graduates. Getting such an email is nice because it tells me that there are other people thinking about similar things to me, and so that my work isn't being completely ignored (it's often hard to tell that otherwise). Particularly, after a day answering banal questions on MO (okay, exaggeration for effect), it's nice to get a question that is actually about something that I'm (supposed to be) an expert on.
That said, don't flood people with questions! Try to remember that such questions are similar to MO - you're asking someone to do you a favour with no real hope of return. Most people are nice and will do their best to help, but make it easy for them to do so. The MO FAQ is a good thing to read: if it would make a good MO question, but you happen to know exactly who's the right person to answer it, you could send them the question (possibly with posting on MO as well? And if they're known to use MO, why not post the question here and send them an email simply saying "I asked this question and I wanted to bring it to your attention as I suspect you'd be the best at answering it.". Bit of flattery, plus as it's on MO, if the person really is too busy then they don't feel too guilty if they can't answer it since someone else will probably have a go. Making it easy again.).