The energy- and density-dependent single-particle potential for nucleons is constructed in a medium of infinite isospin-symmetric nuclear matter starting from realistic nuclear interactions derived within the framework of chiral effective field theory. The leading-order terms from both two- and three-nucleon forces give rise to real, energy-independent contributions to the nucleon self-energy. The Hartree-Fock contribution from the two-nucleon force is attractive and strongly momentum dependent, in contrast to the contribution from the three-nucleon force which provides a nearly constant repulsive mean field that grows approximately linearly with the nuclear density. Together, the leading-order perturbative contributions yield an attractive single-particle potential that is however too weak compared to phenomenology. Second-order contributions from two- and three-body forces then provide the additional attraction required to reach the phenomenological depth. The imaginary part of the optical potential, which is positive (negative) for momenta below (above) the Fermi momentum, arises at second-order and is nearly inversion-symmetric about the Fermi surface when two-nucleon interactions alone are present. The imaginary part is strongly absorptive and requires the inclusion of an effective mass correction as well as self-consistent single-particle energies to attain qualitative agreement with phenomenology.