I know exactly what you mean. The same thing happened to me a couple of days ago. The repair is not for the light of heart.
What I did was first clean the connections on the logic board and socket with rubbing alcohol. Then I carefully super glued the socket in place (using very little glue and making sure the four metal leads on the socket are correctly aligned with the connectors on the board). I used super glue that allowed me thirty second before it set to give me enough time to make a change if needed. Further, I used a small flat edge screw driver to hold the socket in place while setting. I placed the bottom of the case back on without screwing in the screws that secure the part of the case that covers the logic board. I powered up the computer just to check if the subwoofer worked. It did not.
So I flipped the computer back over and took the bottom back off. I used a standard solder iron with a brass spade tip. Steel seems to attract the solder so it sticks to the steel, which I didn't want as I wasn't going to add any solder to the board. With Brass the solder seems to stay in place.
Using the point of the spade, I applied the solder iron to each one of the four leads for about two to three seconds being careful not to melt the plastic.
Without completely securing the bottom case, I turned the Mac back on and tested the speakers. They worked flawlessly. I finished securing the bottom case.