The accuracy of many freehand medical procedures can be improved with assistance from real-time localization. Magnetic localization systems based on harnessing passive permanent magnets (PMs) are of great interest to track objects inside the body because they do not require a powered source and provide noncontact sensing without the need for line-of-sight. While the effect of the number of sensors on the localization accuracy in such systems has been reported, the spatial design of the sensing assembly is an open problem. This paper presents a systematic approach to determine an optimal spatial sensor configuration for localizing a PM during a medical procedure. Two alternative approaches were explored and compared through numerical simulations and experimental investigation: one based on traditional grid configuration and the other derived using genetic algorithms (GAs). Our results strongly suggest that optimizing the spatial arrangement has a larger influence on localization performance than increasing the number of sensors in the assembly. We found that among all the optimization schemes, the approach utilizing GA produced sensor designs with the smallest localization errors.