The first thing is that missiles must be guided by a ship's fire control. Only if that fire control is lost does the missiles internal sensors kick in (how it works isn't 100% clear).
To put the sensors in the missile is simple, just allocate space in the missile design worksheet to the senor you want to use. For a IR missile put in thermal sensors. For a HARM missile put in EM sensors. For Semi-active homing put in an active sensor system.
For a mine, as I understand it the 1st stage has to have an active sensor. The second stage (the part that attacks) also needs a sensor.
In both cases the sensor is put on board by allocating space to sensors in the spreadsheet.
As an example:
The NCN Javelin/Arrow missiles allocate 0.025 MSP to thermal sensors. This gives them a 25,000 km sensor range against emmision 1000 thermal signatures.
The Mk1 Mine has 0.6 MSP active sensors (230,000 km range against size 40 targets), and the Venom missile the mine launches has 0.075 MSP thermal sensors.