If it is an electromagnet, simply turn off the power. If there is any residual magnetism present, you can use AC current through cables wrapped in the form of coils around the piece perpendicular to the residual magnetic field (if the direction can be determined). This will help neutralize the effects of the magnetic field in the piece and help avoid any arc blow. We have had to weld on pipe that came in magnetized, we believe from the Fusion Bonded Epoxy coating process in the oil fields. The fields were so strong, we could hang a large mag-light off of it. The AC coils helped. AC current continuously reverses direction and is the only reliable method for demagnetizing ferromagnetic materials. If it is a permanent magnet, what material is it?