Structural optimization, as the process of finding an optimal material distribution of a machine part, is known from the mechanical engineering, but in the field of the design of electrical machines only few dedicated applications of that method have been reported yet. Most described applications are electromagnetic actuators. This report deals with the problem of finding an optimal structure of the permanent magnets used within a surface mounted permanent-magnet synchronous machine. In contrast to other reported methods, which use continuous models to describe the material properties with a postponed homogenization process, this paper will present a possible solution to the structural optimization problem by a simple heuristic search algorithm. For that purpose, the preselected design area is discretized with suitable quadrilateral cells. The material properties of each cell are set by a simple heuristic search algorithm, while the material properties are chosen from a discrete set of material properties. Therefore, the resulting problem is a discrete optimization problem. The finite-element method is used to solve the magnetic field equations and to gain information about the optimization performance index for each material distribution variant occurring during the optimization process.