Headphones do work in space. https://www.youtube.com/watch?v=qgdqp-oPb1Q You can survive in space for a few moments without oxygen. Afterwards, you're pretty much going to die of asphyxiation. Then your body will freeze. read more
Earphones and headphones do work even in vaccum. But, for the sound produced by those equipment to reach your ear, and for your ear to recognize that sound, there has to be a medium through which the sound can reach your ear drums. read more