For conventional ion traps, the trapping potential is close to independent of the electronic state, providing confinement for ions dependent primarily on their charge-to-mass ratio $Q/m$. In contrast, storing ions within an optical dipole trap results in state-dependent confinement. Here we experimentally study optical dipole potentials for $^{138}\mathrm{Ba}^{+}$ ions stored within two distinctive traps operating at 532 and 1064 nm. We prepare the ions in either the electronic ground ($6{S}_{1/2}$) or one of the metastable excited states ($5{D}_{3/2}$ or $5{D}_{5/2}$) and probe the relative strength and polarity of the potential. On the one hand, we apply our findings to selectively remove ions from a Coulomb crystal, despite all ions sharing the same $Q/m$. On the other hand, we deterministically purify the trapping volume from parasitic ions in higher-energy orbits, resulting in reliable isolation of Coulomb crystals down to a single ion within a radio-frequency trap.