In reality, that Boner from Growing Pains was Walter Koenig's son in real life. It makes that joke even funnier in an episode when Mike Seaver was complaining about writing an english paper to Boner and he says, "Until today I thought Chekov was that Russian guy in Star Trek".
Similarly, ST:TMP's Rhaandarite bridge ensign, Billy Van Zandt, played a cadet in "TAPS". All the cadets were sitting around a TV set watching "Spock's Brain" and Billy's character, Bug, knows what's going to happen... because he's seen all the episodes before.
It was a coincidence that the scene was in the script but his Trek connection added a layer of meaning to the scene as it was shot.
A few years later, Billy was playing a wacky character in TV's "Anything But Love" who, in one episode, turns up to work in a magazine production office brandishing a phaser, which he's just bought from a Star Trek convention downstairs.
A few more years later, Billy Van Zandt's wife, Adrienne Barbeau became the second Senator Cretak in DS9!