In our previous work, we found that only two scenarios are capable of reproducing the observed integrated mass-metallicity relations for the gas and stellar components of local star-forming galaxies simultaneously. One scenario invokes a time-dependent metal outflow loading factor with stronger outflows at early times. The other scenario uses a time-dependent IMF slope with a steeper IMF at early times. In this work, we extend our study to investigate the radial profile of gas and stellar metallicity in local star-forming galaxies using spatially resolved spectroscopic data from the SDSS-IV MaNGA survey. We find that most galaxies show negative gradients in both gas and stellar metallicity with steeper gradients in stellar metallicity. The stellar metallicity gradient tend to be mass dependent with steeper gradients in more massive galaxies while no clear mass dependence is found for the gas metallicity gradient. Then we compare the observations with the predictions from a chemical evolution model of the radial profiles of gas and stellar metallicities. We confirm that the two scenarios proposed in our previous work are also required to explain the metallicity gradients. Based on these two scenarios we successfully reproduce the radial profiles of gas metallicity, stellar metallicity, stellar mass surface density, and star formation rate (SFR) surface density simultaneously. The origin of the negative gradient in stellar metallicity turns out to be driven by either radially dependent metal outflow or IMF slope. In contrast, the radial dependence of the gas metallicity is less constrained because of the degeneracy in model parameters.