In Korean culture, respect for age and seniority is still important and influences how people bow to each other.
There are quite a few rules about when and how to bow, but some general rules of thumb you can use to get you buy are:
Rule 1 - If someone bows to you, return the bow.
Rule 2 - If you are greeting someone older than you or is more senior (e.g. your school principal) you should ALWAYS bow, even if you are just passing them for the 1000th time in the hallway.
These two rules mean you basically bow to everyone unless you are friends or they scan your groceries at your local supermarket.
If you are unsure if you should bow, then bow. You will never offend someone by bowing but you may offend them if you should bow but don't. Worst case is they may think you a little strange if you bow when you don't need to.
Don't just slump your shoulders forward and think that is good enough. When doing a proper bow, you should bend at your waste. The more you bend your body, the more respect you are showing. If for example you are a teacher meeting the school principal for the first time you need to bow quite deep to show your respect.
There are some cases where Koreans will bow so far that their head will touch the floor. They call this a "big bow".
However, generally speaking your body will bend forward between 15 and 45 degrees depending on the situation.
Oh, and when you bow make sure you look down. Don't bow and maintain eye contact with the other person.