As noted above, it varies by institution.
Those that I've worked in have "code teams" which do not include surgeons or surgery residents. These are generally anesthesia and medicine residents and attendings. If they need a line, they generally put one in, and surgery gets called only if they can't get it in.
As for codes on surgery patients, yes - surgery will get called, but unless you are on the floor (which isn't generally the case except for some junior residents), the code team arrives first and by the team someone senior from the surgery team arrives, the code is already well in place. The codes are "ran" by the code team - matter of fact, I got "in trouble" with the code team when I tried to run a code on one of my vascular patients. They had a point - a team needs only 1 leader and they were there first, already running the code.
So there are no hard and fast rules - I've never intubated a patient during a code - doesn't mean I can't, but my hospitals have always had anesthesia present and they've done it.