Mashing too hot, sparging too hot, or too long, boiling grain, and maybe over-crushed grains could be a culprit. I'm not sure about this, but I seem to recall that if you use pilsner malt and don't mash long enough, or boil long enough, that can also cause grainy off-flavors. Can you tell us about your malts and mashing steps?