Season 12, Episode 9
When Homer makes a visit to the doctors it is revealed that part of the reason he is seemingly so dumb is due to a crayon which has been shoved up his nose and into his brain. After having an operation to remove the offending article he becomes a well-spoken genius... which takes away a lot of his innocent charm and loses him a lot of friends, especially as he manages to get Lenny and Carl fired from their jobs.
There are references to King Kong, Runaway Bride and From Here To Eternity.
*Read a more detailed summary for this episode on Wiki Simpsons