Bonanza 33
Flight Crew Air Transport Pilot (ATP); Flight Crew Flight Instructor
Communication Breakdown; Situational Awareness
ATC Issue All Types; Conflict NMAC; Deviation / Discrepancy - Procedural Clearance
Air Traffic Control Issued Advisory / Alert
Human Factors
Upon takeoff the Pilot told the Tower that we would fly westbound off Runway XXL. Shortly after liftoff and climbing out; the pilot; without saying anything to me; turned the airplane to a northwest heading.  An inbound airplane in close proximity passed below us going the opposite direction. We saw it but at the same time it startled the Tower Controller who showed it as a conflict on his radar in the Tower.  He was disturbed at the fact that we turned to the northwest instead of heading west as he had expected.
BE-33 Flight Instructor reported the trainee turned to a heading that was different from what they had communicated to the Tower Controller and caused an NMAC.