If your phone has the logo of a mobile network printed on the outside or on the home screen then it could be locked to that network - but its worth checking with your giffgaff SIM anyway as the presence of a logo doesn't always mean the phone is locked.
Phones that are locked to the O2 network will not require unlocking for a giffgaff SIM to work.
If when you insert your giffgaff SIM and switch the phone on you get a message on the screen saying something long the lines of "SIM card not valid" or "SIM lock" or "Insert correct SIM card" then your phone is very probably locked to another network.
Don't panic - you can almost certainly unlock it so that it works with your giffgaff SIM - see our article on how to unlock here. Remember that stolen phones that have been blacklisted will not work with any network - unfortunately some phones display messages such as "SIM not accepted" if they have been blacklisted making it really hard to tell the difference between locked and blacklisted handsets.