Extensive Langevin dynamics simulations are used to characterize the adsorption transition of a flexible magnetic filament grafted onto an attractive planar surface. Our results identify different structural transitions at different thermal to surface interaction strength ratios: filament straightening, adsorption and the magnetic flux closure. As expected, the adsorption temperature of a magnetic filament is found to be higher in comparison to an equivalent non-magnetic chain. The adsorption has been also investigated under the application of a static homogeneous external magnetic field. We found that the strength and the orientation of the field can be used to control the adsorption process, providing a precise switching mechanism. Interestingly, we have observed that the characteristic field strength and tilt angle at the adsorption point are related by a simple power law.