I use earplugs to prevent outer noise when using headphones and noticed that it changes the music I hear. But how does it change the performance and why?
Your earplugs are doing at least two things to affect the sound you hear from the headphone speakers: reducing the sound pressure, and acting as a frequency filter.
By reducing the sound pressure going into your ears, you are able to increase the volume of the headphones, creating a louder sound from the speakers, which overpowers the "outside" sounds of the headphones.
The earplugs are also creating frequency attenuation, where some frequencies are blocked more than others. I believe that standard foam plugs block mostly high frequencies, around 2k. Plugs can be made to allow or block specific frequency ranges.
For example, many makes of "musician" ear plugs have as even attenuation of the frequencies as possible to make the frequencies sound close to their original relative levels. Specialty plugs for using at a gun range are designed to block the pressure of the gun shot, but still allow frequencies in the speech range.
Rather than using ear plugs with your head phones, you could look into purchasing "noise cancelling" headphones, which block outside noise actively, allowing you to hear the music better without loud volume or intermediate steps such as ear plugs.
The headphones ARE 'outer noise' as far as the earplugs are concerned! They're SUPPOSED to affect the sound! Though it seems a very strange thing to do.