Application of magnetic fields during solidification processes has been reported to control the flow and turbulence in the melt pool and lead to improvements in the microstructure, namely crystallographic orientations and grain size. In order to maximize the benefits of assisting a welding process with externally applied magnetic fields, it is necessary to optimize the weld setup, as the relative distances between magnets and weldment can remarkably affect the magnitude and direction of the applied field. Furthermore, usage of permanent magnets requires an additional caution as ferromagnetic magnets demagnetize as temperature increases, up to the Curie temperature, when they become paramagnetic. This work computationally models magnetically-assisted welding in stainless steel 316L with SmCo26 permanent magnets, while providing a complete account for the heat transfer phenomena and subsequent demagnetization. The number of magnets, the orientation of their poles, and their position relative to the weld for minimal demagnetization and maximum magnetic field in the melt pool are optimized. It was found that three magnetic field orientations concentrate the magnetic strength at the weld, referred to as ‘parallel,’ ‘oblique,’ and ‘perpendicular.’ A 20-cm flat butt joint weldment with optimized arrangements yielded a drop of only 0.21% in the perpendicular arrangement, and as much as 1.53% in the parallel, with initial magnitudes of 0.3325 T and 0.3796 T, respectively.