If you have some business to do at an administration office, like the employment office or the local residents' registration office, then very polite language is called for. Here you greet an official or clerk with "Guten Tag". You shake hands only when the person offers his or her hand; otherwise, you do not.
You must address that person with "Sie" and you will also be addressed formally. Eye contact is also very important. When you say hello and goodbye, you look the person in the eye. You should ask your questions and make your requests politely, and you should thank the clerk for the information or help that they have given you. You say goodbye by saying "Auf Wiedersehen!".