Why do you say 我没有错 instead of 我不错 to say "I'm not wrong"? When should I use 没有? I'm trying to understand when 没有 should be used instead of 不 when negating a sentence.

Consider the example "I'm not wrong."

Why is it 没有错?

How can I know when to use 没有 when negating a sentence? 

谢谢
This particular example is completely idiomatic. 不错 is an adjective meaning 'not bad', the negation of 错 as verb 'to wrong; to mistake' is '没有错'.
Generally 没有 is used in past tense or perfect tense to falsify a statement of fact; 不 is used in present or future tense to express (un)willingness.
没有：

你吃饭了么？Have you eaten?
我没有吃。I haven't.

不：

你吃饭么？Are you going to eat something?
我不吃。No I am not.

Another example to compare the two as answers to the same question:

Q: 他说了么？Did he tell you?
A1: 他没有说。He didn't.
A2: 他不说。He wouldn't tell me.