In this paper we study a distributed control problem for a phase-field system of conserved type with a possibly singular potential. We mainly handle two cases: the case of a viscous Cahn-Hilliard type dynamics for the phase variable in case of a logarithmic-type potential with bounded domain and the case of a standard Cahn-Hilliard equation in case of a regular potential with unbounded domain, like the classical double-well potential, for example. Necessary first order conditions of optimality are derived under natural assumptions on the data.