I believe the initial scene of Eyes Wide Shut is an example for this. I am sure I've heard a fancy term for the use of a piece of soundtrack that turns out to be heard within the film itself. How is that called?
According to TV Tropes, what you're looking for is called diegetic music, or more colloquially Source Music. Switching back and forth in a single scene is simply a "diegetic switch".
TVTropes has other terms for various incarnations of this, some of which are probably "official" and others probably invented by the site's community, e.g.: