When a missile has locked on to you, a message with the missile’s range from you is displayed at the top of your HUD. You have two basic countermeasures. Movement and flares. Flares are deployed with the ALT key. When countering missiles, it is important to always have enough energy for evasive maneuvers with boost.
I recommend waiting until the missile is ~2 km away, popping a flare and then immediately change direction with a boost.
Though do keep in mind that missiles will regularly turn around again for a second try.