Sure. We do this already for MPlayer using a named pipe (gitweb link). Ideally, the player should have a simple "pause" and not a "togglepause" signal, otherwise playback would start if it's paused and you unplug your headphones. What I can offer is a directory like /etc/headphoned.d/ where other packages can install scripts that are executed when the headphones are unplugged. Would this be a workable solution for you?