For $G$ discrete, it is a well-known theorem of Schur that those $G$ such that $G/Z(G)$ is finite are finite-by-abelian, i.e., their derived subgroup is finite. See this survey by Dixon, Kurdachenko, and Pypka.
The locally compact version also holds. Namely, if $G$ is locally compact and $G/Z(G)$ is compact, then $\overline{[G,G]}$ is compact. Indeed, the assumption that $G/Z(G)$ is compact implies that all conjugacy classes in $G$ have compact closure. This implies, by a result of T.S. Wu and Y.K. Yu (Michigan Math. J, 1972) that the closure $\overline{[G,G]}$ the derived subgroup of $G$ is a locally elliptic group, in the sense that every compact subset is contained in a compact subgroup. This applies to the set of commutators in $G$, which is compact (because the commutator map $G^2\to G$ factors through $(G/Z)^2$), and therefore $\overline{[G,G]}$ is compact.