The pilot-in-command of the SF-340A had been issued a takeoff clearance from runway 23, with a restriction to maintain runway heading due to an inbound Cessna 402B approaching from the south, to join a right hand circuit for runway 12. After takeoff, the aircraft was seen to turn right to intercept its planned outbound track, contrary to the takeoff clearance instructions. The turn was observed by both the Tower and Departure Controllers, but too late to effect the required separation. Both aircraft remained in sight of the Tower Controller during the confliction. While the SF-340A was turning it passed within 1.85km horizontally, and less than 1,000ft vertically above the inbound traffic. The co-pilot had recently been endorsed on the aircraft type, and the pilot-in-command advised that he had been distracted during taxi and take-off by slower than normal pre-takeoff checks due to the inexperience of this crew member, and forgot about the after takeoff restriction.