Officers allege the pair injured the man when he grabbed the blade of the weapon during the Banksia Grove incident about 1.50am on June 6.
It is alleged the men left the driver on the roadside after stealing the vehicle.
Police found the car abandoned and damaged in Yanchep.
Investigators raided a Yanchep home where one of the men was allegedly in possession of a pen gun and drug paraphernalia.
The 22-year-old resident of the property was charged with aggravated armed robbery, vehicle theft, criminal damage, aggravated possession of a firearm and possession of drug paraphernalia.
A 24-year-old man of no fixed address was charged with aggravated armed robbery, vehicle theft, criminal damage and driving without a licence.