Mount the light on the rifle. Because there are a number of designs for the AR, as well as for the various lights on the market, follow the instructions for mounting your light near the muzzle of your rifle. If your light comes with its own system for mounting the pressure switch, consider doing it that way.
Choose the best location for the switch. The ideal location is where your forward support hand will naturally rest when you are using the rifle, normally on the barrel rail or a vertical forward grip. The pressure switch is designed for this, so you can turn the light on and off simply by gripping the rifle more or less firmly. Moving your support hand to manipulate the light would create a tactical disadvantage.
Attach the pressure switch to the rifle. The simplest way is to stick double-sided tape to the flat side of the switch and press it onto the barrel rail or forward grip wherever you want it. If you prefer, you could also glue a small super magnet to the switch, then attach it to the metal rail.
Use a store-bought solution. Several manufacturers sell barrel rail covers and forward grips that have pockets and sleeves to accommodate pressure switches. These accessories work with most AR-15 models. They are more presentable than tape and magnets, but they may place the switch in a location that is not comfortable as you grip your rifle.