I once played in a short adventure as the only player replaying it in an otherwise different group of players. The DM was reluctant to allow me to play the module a second time, but needed one more player, and allowed it on the condition that the first time I tried to use my knowledge from the previous time I had played, I was out of the game (as if it was a forgone conclusion that I would do so eventually.)
At one point, I saw an opportunity to pursue a different path than I had when I had played previously, and wanting to explore that avenue, suggested it in-character. The DM immediately halted the scene, declaring “That’s it! You’re out! I told you you weren’t allowed to use your knowledge of the module to influence anything!”
This DM already presumed malice on your part, and was looking for any opportunity to punish you for your actions. A DM should never get into the mind of the PC's like that, in my opinion. Nor should metagaming ever be this much of a concern. The goal of the DM and the players should always be to have fun. We don't just act upon pc knowledge, but we also act upon what we as players believe will create the most entertainment.
When I replayed my Call of Cthulhu campaign with the same player, he made sure to stay clear of a trap that he had fallen into the first time, by having his character conveniently be elsewhere at that moment in time. What this player was doing, was making sure that other players got to experience the same shock and horror as he did the first time around. This was something we had agreed upon together: He would explore other angles of the same story, and not spoil any surprises for the other players. That was all. He could metagame as much as he wanted, and use it to seek out fun new areas and situations with a new character. He could see how other players would act when put in the same situation as he was.
And that is a ton of fun for both the DM and the player in question.
Often when I am a player, I will intentionally send my character into situations that are bound to create interesting play. I once had my barbarian attend a dinner with the rich upper class, and try to blend in. It was hilarious. He would burp at the table, use the wrong cutlary for each course consistently, or try to eat something with his bare hands, and accuse a nobleman of making up words that he just didn't know (or try to seem educated, by using a word incorrectly). The session had everyone dying with laughter. I knew this would not go well for my character, and end in total disaster. But I had my barbarian insist on being there, consequences be damned!