Cetuximab and panitumumab are monoclonal antibodies that target the epidermal growth factor receptor (EGFR). Treatment with cetuximab and panitumumab commonly causes hypomagnesemia, and optimal management of this adverse effect remains unclear. Here, we evaluated the optimal magnesium replacement points based on the risk of severe hypomagnesemia in colorectal cancer patients who received cetuximab or panitumumab. We retrospectively evaluated 184 patients who received cetuximab or panitumumab for colorectal cancer at Ogaki Municipal Hospital (Ogaki, Japan) between January 2010 and December 2019. Univariate analyses were conducted to evaluate the relationship between patient baseline characteristics and development of hypomagnesemia following cetuximab or panitumumab treatment. Variables that were significantly associated with hypomagnesemia in the univariate analyses as well as previously reported risk factors were entered into a multivariate logistic regression model. The incidence of hypomagnesemia was associated with panitumumab treatment, pre-replenishment serum magnesium concentration, treatment duration, and treatment line. Severe hypomagnesemia post-cetuximab or panitumumab treatment was significantly associated with low baseline magnesium concentrations (< 1.8mg/dL; odds ratio 18.100, 95% confidence interval 1.570-210.000; p = 0.020) and low serum magnesium concentrations during treatment (< 1.1mg/dL; odds ratio 93.800, 95% confidence interval 3.510-2510.000; p = 0.007). To minimize the risk of severe hypomagnesemia during anti-EGFR treatment, magnesium replenishment should be initiated in patients with pre-replenishment concentrations of < 1.8mg/dL, preferably before reaching intra-treatment concentrations of < 1.1mg/dL.