Core files should never be modified. This is more than likely due to one of two reasons.
a) A plugin has placed this code into one of the core files. If this is the case, you probably shouldn't be using that plugin. A good plugin developer would know not to modify core files.
b) Your site has been compromised, and the script was maliciously injected.
Either way, the easiest way to resolve the issue is to re-upload the core files. I would recommend disabling any plugins you do have to ensure that this is not the issue. Once you re-upload, re-enable each plugin one at a time to see if it adds the script. If so, you know where the issue lies. If the plugins do not add the code, than your site was probably compromised, in which case you should check your server settings.