One of the big challenges of the emerging MRI-guided radiotherapy is the prediction of an external magnetic field effect on the deposited dose induced by a beam of charged particles. In this paper, we present the results of the implementation of the Lorentz force in the deterministic M1 model. The validation of our code is performed by comparisons with the Monte-Carlo code FLUKA. The relevant examples show a significant modification of the shape of dose deposition volume induced by the external magnetic field in presence of heterogeneities. A gamma-index analysis 3%/3mm shows a good agreement of our model with FLUKA simulations.