How do I install an occupancy sensor at a switch with only two wires?
If you mean there are only two wires at the switch then you cannot use a typical occupancy sensor at this location.

This type of switching is called a switch loop. The hot is brought down on the white and the switched black goes up to turn on the light. There is NO neutral wire in a two-wire switch loop. 

This is why new codes require a neutral wire at a switch box location, even with a switch loop.

The ground should be connected to the ground wires in the box. If none exist, or the box is metallic and grounded, then just fold the ground wire into the box behind the switch. 
You should definitely check the instructions to see if the ground is absolutely required. Switches in existing applications that are non-grounding can be replaced with new, but some electronic switches require a valid grounding conductor.