  A perfect code $C$ in a graph $\Gamma$ is an independent set of vertices of
$\Gamma$ such that every vertex outside of $C$ is adjacent to a unique vertex
in $C$, and a total perfect code $C$ in $\Gamma$ is a set of vertices of
$\Gamma$ such that every vertex of $\Gamma$ is adjacent to a unique vertex in
$C$. Let $G$ be a finite group and $X$ a normal subset of $G$. The Cayley sum
graph $\mathrm{CS}(G,X)$ of $G$ with the connection set $X$ is the graph with
vertex set $G$ and two vertices $g$ and $h$ being adjacent if and only if
$gh\in X$ and $g\neq h$. In this paper, we give some necessary conditions of a
subgroup of a given group being a (total) perfect code in a Cayley sum graph of
the group. As applications, the Cayley sum graphs of some families of groups
which admit a subgroup as a (total) perfect code are classified.
