They can peck the grain or peck at it, implying they don't always manage to pick it up. Pecking in the grain I suppose implies they are pecking surrounded by grain so they are IN the grain. Also they could be reaching into a container of grain and then they would be pecking in the grain, meaning in the pot containing the grain.