GoodFellas

Martin Scorsese chose the songs for Goodfellas only if they commented on the scene or the characters "in an oblique way". The only rule he adhered to with the soundtrack was to only use music which could have been heard at that time.
For example, if a scene took place in 1973, he could use any song that was current or older. According to Scorsese, a lot of non-dialogue scenes were shot to playback. For example, he had "Layla" playing on the set while shooting the scene where the dead bodies are discovered in the car and the meat-truck. Sometimes, the lyrics of songs were put between lines of dialogue to comment on the action.
Some of the music Scorsese had written into the script while other songs he discovered during the editing phase. There is no music once Henry is arrested in his driveway by the DEA, until the end credits.