Sometimes it works, sometimes it doesn't. When I have to write something (this blog post for example) or need to come up with a visualization for a tricky concept, background music disturbs me. It like the melody of the music highjacks my brain and takes things in a different direction than the storyline in front of me.
Cleaning up charts (make-over work), or building financial/economical models works great with music in the background though.
That's maybe why many people end up writing things late at night: finally it is quiet.
Image from WikiPedia