A new efficient and flexible optimization technique based on the black hole phenomenon is proposed for the optimization of electromagnetic devices. It is called the black-hole-based optimization technique. In order to show the effectiveness of the proposed technique, it has been demonstrated on a magnetizer by optimizing its pole face to obtain a desired magnetic flux density distribution. Based on the desired profile of the magnetic flux density two cases are studied corresponding to a constant profile and to a sinusoidal profile. The quality of the results obtained shows that it is a promising alternative technique for electromagnetic devices optimization.