Recently, the application of magnetic fields by permanent magnets during welding has been reported to improve the quality of welded joints. It has been shown that magnetically-assisted welding leads to homogeneous solidification, and improvements in crystallographic orientations and grain size, resulting in enhanced mechanical properties and reduced part distortion. It is known that ferromagnetic permanent magnets demagnetize as temperature increases, up to the Curie temperature when they become paramagnetic. So far, the reported simulations in the literature do not account for temperature-induced demagnetization in magnetically-assisted welding, which is a significant phenomenon due to typically compact fixture arrangements. This work simulates magnetically-assisted welding in Stainless Steel 316L, while accounting for all the mechanisms of heat transfer and subsequent demagnetization. In addition, the necessary magnetization and arrangement of permanent magnet(s) are optimized in order to get the required field in the melt pool.