Said when you did something 'wrong' or something 'stupid'. Well, if you're well adjusted, you'll say it. If you're not, you'll yell and scream like a little baby, but I digest..
the 'chalk it up' part probably alludes to sports, where, a while back, scores were kept on slates, so it implies some sort of match, were the 'point' went not to you.
In modern, verbose english, it would be scribed as "I will learn from my mistake."