Although we, in English, don't really use a different form when speaking formally, Germans distinguish between the formal and the informal depending on who they are speaking to. The first basic rule of this is that if the person that you are speaking to is older than you or in a higher position, eg. your boss, your teacher or professor, then you use the formal. Also if you are speaking to a stranger, eg. a customer in a shop or asking for directions, you still use the formal.
You only use the informal form 'du' when speaking to friends, family, children or when you have agreed to use the 'Du' form-(usually soon after introductions). If in doubt, you should probably use the formal, nobody will be offended and if they want to be more familiar they will suggest using the 'du' form.