The spectral index of synchrotron emission is an important parameter in understanding the properties of cosmic ray electrons (CREs) and the interstellar medium (ISM). We determine the synchrotron spectral index ($alpha_{rm nt}$) of four nearby star-forming galaxies, namely NGC 4736, NGC 5055, NGC 5236 and NGC 6946 at sub-kpc linear scales. The $alpha_{rm nt}$ was determined between 0.33 and 1.4 GHz for all the galaxies. We find the spectral index to be flatter ($gtrsim -0.7$) in regions with total neutral (atomic + molecular) gas surface density, $Sigma_{rm gas} gtrsim rm 50~M_odot pc^{-2}$, typically in the arms and inner parts of the galaxies. In regions with $Sigma_{rm gas} lesssim rm 50~M_odot pc^{-2}$, especially in the interarm and outer regions of the galaxies, the spectral index steepens sharply to $<-1.0$. The flattening of $alpha_{rm nt}$ is unlikely to be caused due to thermal free--free absorption at 0.33 GHz. Our result is consistent with the scenario where the CREs emitting at frequencies below $sim0.3$ GHz are dominated by bremsstrahlung and/or ionization losses. For denser medium ($Sigma_{rm gas} gtrsim rm 200~M_odot pc^{-2}$), having strong magnetic fields ($sim 30~mu$G), $alpha_{rm nt}$ is seen to be flatter than $-0.5$, perhaps caused due to ionization losses. We find that, due to the clumpy nature of the ISM, such dense regions cover only a small fraction of the galaxy ($lesssim5$ percent). Thus, the galaxy-integrated spectrum may not show indication of such loss mechanisms and remain a power-law over a wide range of radio frequencies (between $sim 0.1$ to 10 GHz).