Breakaway is no longer maintained on its website, but it can still be downloaded from Sourceforge. I've associated it with the following two AppleScripts to mute the speaker and pause Spotify when the jack is disconnected, and to play Spotify when the jack is connected. Follow the instructions on makeuseof to see how to author AppleScript and connect it to Breakaway.
jack-disconnected.scpt
set volume output volume 0
tell application "System Events"
set MyList to (name of every process)
end tell
if (MyList contains "Spotify") is true then
tell application "Spotify" to pause
end if
jack-connected.scpt
tell application "System Events"
set MyList to (name of every process)
end tell
if (MyList contains "Spotify") is true then
tell application "Spotify"
if player state is paused then play
end tell
end if