How do you know your own beliefs? And how well do you know them? The two questions are related. I'll recommend a pluralist answer to the first question. The answer to the second question, I'll suggest, varies depending on features of the case.
Self-scanning. Shaun Nichols and Stephen Stich (2003) say this: You have in your mind a functionally defined “belief box.” To believe some propositionP is just to have a representation with the content “P” in the belief box. You also have a monitoring mechanism that can scan the contents of the belief box. Normally, you come to know what you believe by deploying that scanner, creating a new belief in the belief box, a belief with the content “I believe thatP.” Self-scanning accounts admit of many possible variations and complications (e.g., Armstrong 1968, 1981, 1999; Lycan 1996; Goldman 2006), but the basic idea is that people have one or more interior monitors or scanners that detect the presence of beliefs and produce, as output, beliefs about those beliefs (or judgments about those beliefs, or representations of those beliefs).