The code is wrong to begin with (the original one, I mean), because it uses \if,#1, which is not a safe test for emptiness of #1. The problem is that \if expands tokens; in your case it works, because the expansion of \frac doesn't begin with a comma. But similar code might give problems if used in different contexts.
You want to first process the first item in the comma separated list and then start the recursion, where the \middle| is placed before the other items.
\documentclass[12pt]{article}
\def\punkt#1{\left(\punktA#1,,\right)}
\def\punktA#1,{#1\punktB}
\def\punktB#1,{%
\if\relax\detokenize{#1}\relax % safe test for emptiness
% do nothing in the true case
\else
,\middle|,#1% delimiter and item
\expandafter\punktB % restart the recursion
\fi
}
\begin{document}
$\punkt{}$
$\punkt{a}$
$\punkt{a,b}$
$\punkt{\frac{1}{\pi},2,3}$
\end{document}

You see that it also works with an empty argument.
Of course, the \clist_use:nn approach suggested by David is much simpler and requires almost no thinking.
With a more natural input syntax:
\documentclass[12pt]{article}
\ExplSyntaxOn
\NewDocumentCommand{\punkt}{m}
{
\left(
\seq_set_split:Nnn \l_tmpa_seq { | } { #1 }
\seq_use:Nn \l_tmpa_seq { ,\middle|, }
\right)
}
\ExplSyntaxOff
\begin{document}
$\punkt{}$
$\punkt{a}$
$\punkt{a|b}$
$\punkt{\frac{1}{\pi} | 2 | 3}$
\end{document}
The output is the same. Spaces around | are ignored.