I was wondering if a locked iPhone (with a contract of 2 years) can be updated to iOs 7 and still working well and under the same contract.
There is no reason this should not work. Assuming your model supports iOS 7 of course.
I'd like to be abel to tell you more. But there is just not much to say.
The lock to a certain provider is not affected by an upgrade to iOS 7. Provider settings will just be the same as well.