Moved it to the appropriate section for you.
It depends on the model of phone, but sporadically working is not a sign of any SIM-lock. Which model is it?
First Samsung is protecting there phones for exports. If you buy a Samsung phone in e.g. Germany you have to use the phone for one hour with a German SIM card! That has nothing to do with O2. If you do not use the phone with a German SIM Card bevor that you have to contact Samsung support!
if the phone has a Net lock or Sim Lock the phone tells you on the screen. Than you could use the phone only in O2 network you can buy than a code to get a free phone bevor the 2 years.
But sim or net lock are not very common…
so I think the first option is the problem.