Sharp, or Flat?
In the context of a piece of music, notes must be named for their diatonic functionality. For example, in the key of D major, it is not generally correct to specify G♭ as a melodic note, although its pitch may be the same as F♯. This is normally only an issue in describing the notes corresponding to the black notes of the piano; There is little temptation to write C as B♯ although these are both valid names of the same note. Each is correct in its context.
Note names are also used for specifying the natural scale of a transposing instrument such as a clarinet, trumpet or saxophone. The note names used are conventional, for example a clarinet is said to be in B♭, E♭, or A (the three most common registers), never in A♯ and D♯ and B (double-flat), while an alto flute is in G.
Read more about this topic: Letter Notation