When can a (finite) group be written as the quotient of some other group by its center?
The groups you are looking for are called capable groups. The determination of all capable group (even all finite capable groups) is very far from done.
The earliest result is due to Baer, who characterized exactly which groups that are direct sums of cyclic groups are capable (Baer, Reinhold. Groups with preassigned central and central quotient groups, Trans. Amer. Math. Soc. 44 (1938), 387-412; in fact Baer considered the question of when a group has a specified center and central quotient, each of which is a direct sum of cyclic groups. You obtain the characterization of capable groups as a corollary). For finitely generated abelian groups, this becomes:
Theorem. Let $G$ be a finitely generated abelian group, written as a direct sum of cyclic groups $$G = C_{a_1}\oplus\cdots\oplus C_{a_n}$$ with $a_1|a_2|\cdots|a_n$ ($C_0$ denotes the infinite cyclic group). Then $G$ is capable if and only if $n\gt 1$ and $a_{n-1}=a_n$.
There is a generalization of this result, replacing abelian groups with $p$-groups and replacing the direct sum with the nilpotent product (Capability of nilpotent products of cyclic groups and Capability of nilpotent products of cyclic groups II, J. Group Theory 8, no. 4 (2005), 431-452; and J. Group Theory 10 no. 4 (2007), 441-451):
Theorem. Let $p$ be a prime and let $c$ be a positive integer, $c\leq p$. If $G$ is the $c$-nilpotent product of cyclic groups $$G = C_{p^{a_1}}\coprod^{c}\cdots\coprod^{c} C_{p^{a_n}}$$ where $\coprod^{c}$ represents the $c$-nilpotent product, and $1\leq a_1\leq\cdots\leq a_n$. Then $G$ is capable if and only if $n\gt 1$ and $a_n\leq a_{n-1}+\lfloor\frac{c-1}{p-1}\rfloor$
The last condition is in fact necessary in general for $p$-groups:
Theorem.(2005) Let $G$ be a nilpotent $p$-group of class $c\gt 0$, and let $x_1,\ldots,x_n$ be a generating set for $G$ with $x_i$ of order $p^{a_i}$, $a_1\leq a_2\leq\cdots\leq a_n$. If $G$ is capable, then $n\gt 1$ and $a_n\leq a_{n-1}+\lfloor\frac{c-1}{p-1}\rfloor$.
The extra-special capable $p$-groups were not classified until 40 years after Baer (F.R. Beyl, U. Felgner, and P. Schmid. On groups ocurring as central factor groups, J Algebra 61 (1979), 161-177). The only extra-special capable $p$-groups are the nonabelian groups of order $p^3$ and exponent $p$.
Aside from these classes, there is a full classification of the capable $2$-generated $p$-groups of class two. You can find it the paper (with Robert F. Morse) Certain homological functors for $2$-generated $p$-groups of class 2, in Computational Group Theory and the Theory of Groups II, Contemporary Mathematics 511 (2010), pp 127-166, American Mathematical Society.
There are lots of known necessary conditions, but in general sufficient conditions are harder to find. Phillip Hall commented 70 years ago (The classification of prime-power groups, J. Reine Angew. Math. 182 (1940) 130-141) that:
The question of what conditions a group $G$ must fulfil in order that it may be the central quotient of another group $H$, $G\cong H/Z(H)$, is an interesting one. But while it is easy to write down a number of necessary conditions, it is not so easy to be sure that they are sufficient.