Faulty SIM

In the last few days my mobile SIM is intermittently NOT recognised by my phone. When I remove it and replace it works for a short while and fails again. How do I get a replacement for an iPhone5 and what is tha cost if any.