I'm going to disagree slightly with the mostly very good answers here.
You should always go to your manager first, except in a few cases. Other than the obvious one (when the issue is with your manager):
- Clear knowledge of an ethical breach that violates the law
- A major incident of a physical or sexual nature (major meaning of the level you would consider going to the police next, or could potentially take legal action, even if you don't plan to)
- Clear knowledge of a security breach
That's not an exhaustive list, but in cases like that - basically, cases where there is a time-sensitive, potentially legally damaging issue, it is correct to go to the appropriate department - in some companies, this would be HR for all three of these, in some companies only really the major physical/sexual incident would be.
In the case of an ethical or a security breach, most larger companies will have explicit instructions how to handle these - usually an ethics hotline for anonymously reporting ethical violations, and some sort of email address to report information security breaches.
In any other case, you should go to your manager. And if you do have an incident like the above, you should tell your manager as soon as possible afterwards, unless you are uncomfortable discussing it with them. If you're uncomfortable discussing the specific incident, you might simply let them know that you needed to talk to HR/etc. about an issue that you're not comfortable discussing further, but so that they know something is going on and aren't blindsided. The worst thing as a manager is to be blindsided by an issue on your team, even if it's not something you could've done something about.