There are numerous ways to do this.
One way is to use \ifdefined:
\documentclass{article}
%\newcommand*{\DEBUG}{}%
\begin{document}
\ifdefined\DEBUG
DEBUG was on
\else
DEBUG was off
\fi
\end{document}
Another is to use a \newtoggle defined by the etoolbox package:
\documentclass{article}
\usepackage{etoolbox}
\newtoggle{DEBUG}
\toggletrue{DEBUG}
%\togglefalse{DEBUG}
\begin{document}
\iftoggle{DEBUG}{
DEBUG was on
}{
DEBUG was off
}
\end{document}
The same pacakge also provides a newbool with similar functionality:
\documentclass{article}
\usepackage{etoolbox}
\newbool{DEBUG}
\booltrue{DEBUG}
%\boolfalse{DEBUG}
\begin{document}
\ifbool{DEBUG}{
DEBUG was on
}{
DEBUG was off
}
\end{document}
See Difference between \newbool and \newtoggle from etoolbox package for a discussion of these two.
Another is to use the xstring package:
\documentclass{article}
\usepackage{xstring}
\newcommand{\DEBUG}{ON}%
\begin{document}
\IfStrEq{\DEBUG}{ON}{
DEBUG was on
}{
DEBUG was off
}
\end{document}
Or use the ifthen package. But do make a note of Why is the ifthen package obsolete? if considering this solution.
\documentclass{article}
\usepackage{xifthen}
\newcommand{\DEBUG}{ON}%
\begin{document}
\ifthenelse{\equal{\DEBUG}{ON}}{
DEBUG was on
}{
DEBUG was off
}
\end{document}
Over time I have used all the options (and stayed away from xifthen due to comments at link regarding that this package is obsolete), but tend to gravitate to \ifdefined when doing quick tests, and use etoolbox approach for more longer term solutions for on/off conditions, and the xstring approach when there are more conditions to consider.
As @Seamus mentions there is a \newif built in, but I have tended to avoid that as I did not like the syntax and had to look it up every time, but that is just a personal preference