We exploit free-space interactions between electron beams and tailored light fields to imprint on-demand phase profiles on the electron wave functions. Through rigorous semiclassical theory involving a quantum description of the electrons, we show that monochromatic optical fields focused in vacuum can be used to correct electron beam aberrations and produce selected focal shapes. Stimulated elastic Compton scattering is exploited to imprint the required electron phase, which is proportional to the integral of the optical field intensity along the electron path and depends on the transverse beam position. The required light intensities are attainable in currently available ultrafast electron microscope setups, thus opening the field of free-space optical manipulation of electron beams.