It is all in your head, but it's not at all easy to fix. The brain's perception of reality is all we have, and when that perception is skewed it can be very hard to find something to help un-skew it.
That's what he is saying in a bad way. The people in the comic are technically right, but since you think you deserve the punishment, you are stuck. If you manage to get away from that negative thinking, you've done the biggest part of getting out of depression, and from there it is easier to do the rest without the destructive self esteem.
Fixing the thought that you deserve it is the hard part. It's a self-reinforcing worldview that colors everything that comes in. People can say exactly the right thing, but depression will twist the way that you perceive their words.