I have done some research both online and in real life (all in Japanese) but failed to find any reliable information as to exactly when or how it added the new usage. So, this will mostly be a non-answer.
Adoration and contempt are both sides of the same coin and the line between the two sides is fragile. It would not be unusual using an honorific to show respect to someone in public and simultaneously using the same "honorific" in a derogatory way in one's privacy to express one's true feelings toward the same person. After all, the walls have ears.
Regarding the suffix 「[公]{こう}」, its derogatory usage is limited to highly colloquial conversations, and believe it or not, it is not at all in wide use. The only words containing 「公」 that I have actively used or heard others use have been 「[先公]{せんこう}」 and 「ポリ[公]{こう}」 (meaning "teacher" and "cop", respectively) , and it was only during junior high school. It just was not cool to continue using those words in high school. It should be noted that even in junior high, kids used those words mainly because it was the fad to do so at that time, not because we were delinquents who had grudges against our teachers and the police.
The only reason that I feel that Japanese-learners might be mislead to thinking that 「公」 is in wider use is that it is used much more often in fiction. In real life, we do not speak like the characters one sees in manga, anime, films, etc.
If OP's dictionary actually said that 「[熊公]{くまこう}」 was derogatory, it is NOT. It only means "little beary boy". It is totally different from 「熊め」, which means "that f***ing bear".