From The Apple Wiki

The W1 chip is an Apple-branded processor, used in the AirPods (1st generation).

It allows the AirPods to detect when they are in your ears, using optical sensors and a motion accelerometer. It also allows the AirPods to automatically route audio to the AirPods when they are connected.

A new revision, the W2, was added to the Apple Watch Series 3.