I don't think there is really an exact rule about this. Here's what the Russian Self Teaching Guide has to say:

"Many nouns of more than one syllable ending in -ец and -ок behave in this way."
...