It's OK, but "this" in the sense you probably intend it is casual conversational usage. Except in casual writing, it would be better to say "got an annoying headache".
It is possible, but not very likely, that "this" could be used in this sentence in a formally grammatically correct way -- to refer to a headache that had been previously mentioned, for example.