It’s either when we use accidentals in a scale or when we move in semitones. If we assume that we’re in C major, we won’t go in ascending order like: C-D-E-F-G. We’ll also add sharps as in: C-C#-D-D#-E-F-F#-G. We just add all those little black keys too (visualize a piano’s keyboard). As far as the notation is concerned, it’s common to use sharps when ascending and flats when descending.