We report a measurement of the νμ inclusive charged current cross sections on iron and hydrocarbon in the T2K on-axis neutrino beam. The measured inclusive charged current cross sections on iron and hydrocarbon averaged over the T2K on-axis flux with a mean neutrino energy of 1.51 GeV are (1.444±0.002(stat.)+0.189−0.157(syst.))×10−38cm2/nucleon, and (1.379±0.009(stat.)+0.178−0.147(syst.))×10−38cm2/nucleon, respectively, and their cross section ratio is 1.047±0.007(stat.)±0.035(syst.). These results agree well with the predictions of neutrino interaction model and thus demonstrate the correct treatment of the nuclear effect for iron and hydrocarbon targets in the model.