Accidentals

When you are using music notation, how do you know when you are supposed to use a sharp vs a flat?