Put section and page numbers in the margin with KOMA-Script

The source code of l2tabu is available on CTAN. There you can read it:

\renewcommand*{\othersectionlevelsformat}[1]{%
  \makebox[0pt][r]{\csname the#1\endcsname\autodot\enskip}}

The section number is put into a box of width 0, right aligned. So it runs into the left margin.


Update

With KOMA-Script version 3.19a or newer you simple have to redefine \sectionlinesformat to get the desired result:

\documentclass{scrartcl}[2015/10/03]

\renewcommand\sectionlinesformat[4]{%
  \makebox[0pt][r]{#3}#4%
}

\usepackage[headwidth=textwithmarginpar]{scrlayer-scrpage}
\clearpairofpagestyles
\ohead{\pagemark}
\usepackage{blindtext}
\begin{document}
\Blinddocument
\end{document}

Original answer

Since KOMA-Script version 3.17 (current version on CTAN) you have to redefine the commands \sectionformat, \subsectionformat etc. instead \othersectionlevelsformat.

\documentclass{scrartcl}[2015/04/23]
\renewcommand\sectionformat{\makebox[0pt][r]{\thesection\autodot\enskip}}
\renewcommand\subsectionformat{\makebox[0pt][r]{\thesubsection\autodot\enskip}}
\renewcommand\subsubsectionformat{\makebox[0pt][r]{\thesubsubsection\autodot\enskip}}

\usepackage[headwidth=textwithmarginpar]{scrlayer-scrpage}
\clearpairofpagestyles
\ohead{\pagemark}

\usepackage{blindtext}
\begin{document}
\Blinddocument
\end{document}