Commercial Fixed Wing
Flight Crew Air Transport Pilot (ATP)
Situational Awareness; Communication Breakdown
ATC Issue All Types; Deviation - Track / Heading All Types; Deviation / Discrepancy - Procedural Clearance
Air Traffic Control Issued New Clearance; Flight Crew Requested ATC Assistance / Clarification
Human Factors
We were cleared for takeoff on Runway XR in ZZZ.  Both myself and the other pilot heard the phrase from the Controller 'Runway XR cleared for takeoff.'  We did not hear any other instructions.  We were on the ZZZZZ 2 departure.  It states to fly heading 011 until reaching 820 feet then heading 340 or assigned by ATC.  We started our turn at 820 feet and a few seconds later the Controller told us to immediately turn and fly runway heading.  No other problems came about from this situation.  It seems like there was some miscommunication between the pilots and ATC.  We were flying the appropriate procedures and did not hear ATC tell us to fly runway heading you're cleared for takeoff Runway XR.  Both pilots only heard 'Runway XR cleared for takeoff.'
Departing Runway XR we were cleared for takeoff. We followed the SID heading of 340 when ATC told us runway heading. After correcting to runway heading we discussed the departure and both of us were sure that we were just cleared for takeoff with no other instructions. We were both mistaken - he did issue runway heading on the takeoff clearance. Having been unfamiliar with this airports procedures I may have had some expectation bias towards just flying the SID and clearly missed the runway clearance; not to mention having not flown since April [and] a bit of tunnel vision during the before takeoff.
Air carrier flight crew reported a track heading deviation.