This article presents a new approach for detecting active sources in the cortex from magnetic field measurements on the scalp in magnetoencephalography (MEG). The solution of this ill-posed inverse problem is addressed within the framework of maximum entropy on the mean (MEM) principle introduced by Clarke and Janday. The main ingredient of this regularization technique is a reference probability measure on the random variables of interest. These variables are the intensity of current sources distributed on the cortical surface for which this measure encompasses all available prior information that could help to regularize the inverse problem. This measure introduces hidden Markov random variables associated with the activation state of predefined cortical regions. MEM approach is applied within this particular probabilistic framework and simulations show that the present methodology leads to a practical detection of cerebral activity from MEG data.