Why are we discussing how to drill huge holes through the Earth, anyway? Given the strength of the Earth's gravitational field versus the Moon's, it'll be far more effective to build it on the Moon instead. Also, the Earth is currently our only source of agriculture and resources at the moment, so it probably wouldn't be wise to harm it too much.
Anyway, regarding Itnetlolor's idea of attaching rotational boosters to the Earth to counteract the opposing force that the railgun generates; wouldn't it make more sense to use the fuel for those boosters for plain old chemical rockets instead? That wouldn't require a huge amount of manpower and resources to construct a railgun in the first place.
Regarding your original idea: It's cool to think about, but also really impractical. Even the entire human race would take centuries just to excavate the tunnel, and there's the problem of the magma that's in the way for most of the tunnel. While in the tunnel itself, a potential payload would burn up due to air resistance about a quarter of the way through, if it wasn't already melted by the intense temperature. Also, where were you get the truly enormous amounts of energy needed to power the electromagnets for the tunnel? Also, I doubt that the short length of the muzzle (as compared to the tunnel) would be sufficient to significantly change the trajectory of the spacecraft launching. Finally, once the tunnel was dug, where would we store all the displaced earth?
*snip*
Dang o_o Wouldn't the uh... railgun part have to be in an airtight vacuum tube, because of the friction that comes from air itself? You'd get more speed and less chance of incinerating yourself before liftoff :3
Ninjaedit: Keeping the entire tunnel an airtight vacuum for its length would necessitate either building huge gates at each end (which would be useless the instant they were opened) or building a wall that literally pokes out of the atmosphere.