Ensemble optimal control problems governed by a Fokker–Planck equation with space–time dependent controls are investigated. These problems require the minimisation of objective functionals of probability type and aim at determining robust control mechanisms for the ensemble of trajectories of the stochastic system defining the Fokker–Planck model. In this work, existence of optimal controls is proved and a detailed analysis of their characterization by first– and second–order optimality conditions is presented. For this purpose, the well–posedness of the Fokker–Planck equation, and new estimates concerning an inhomogeneous Fokker–Planck model are discussed, which are essential to prove the necessary regularity and compactness of the control–to–state map appearing in the first–and second–order analysis.