I defined a new command,
\newcommand{\Test}[1][p]{\ensuremath{n_{\mathrm{dof}}^{\mathrm{Q#1}} }}
with one optional argument, which is either 1 or 0. If I call \Test without the parameter, I get the desired output, that is the correct subscript Qp. However, calling \Test{2} gives the subscript Qp either and the argument 2 is located elsewhere. My intuition is to retrieve Q2 in case of calling \Test{2}.
I can add a picture if necessary but I hope it is clear what I refer to.
Is there something I do not encounter correctly?

\mathrmthat your lije be saved ;-) – Zarko Aug 19 '21 at 11:56\ensuremathwas wreaking havoc in such a sneaky way that it took me hours to work out. Admittedly, I was an absolute TeX novice and didn't know how to debug properly. Anyway, I learnt to separate math from text and not to rely on laziness. Have a look at https://tex.stackexchange.com/q/34830/82917 for some discussion. – campa Aug 19 '21 at 12:48