In the key of D major, the scale consists of the notes: D, E, F#, G, A, B, C#. Each note in a major scale has a specific scale degree name:
D - Tonic (1st degree)
E - Supertonic (2nd degree)
F# - Mediant (3rd degree)
G - Subdominant (4th degree)
A - Dominant (5th degree)
B - Submediant (6th degree)
C# - Leading note (7th degree)
The note B is the 6th degree of the D major scale, which is called the submediant. The submediant gets its name because it is a third below the tonic (the "median" below), just as the mediant is a third above the tonic.
A common mistake is confusing the submediant with the subdominant. The subdominant is the 4th degree (G in D major), while the submediant is the 6th degree (B in D major). To avoid this error, write out the full scale and count the position of the note in question.