I don't think anyone knows. My "Grampa" was born in 1886 and raised in NYC. He and his friends employed the expression when one of the Irish cops, for whom they had the utmost respect, loomed near. He didn't know the origin of the phrase, but was sure it wasn't Hollywood.
"It was originally British slang of the early nineteenth century, but was later taken to the US — it turns up, for example, in a story in O Henry’s The Voice of the City, published in 1908....It’s also in The Inimitable Jeeves by P G Wodehouse, published in 1923....The first example occurs in James Hardy Vaux’s A New and Comprehensive Vocabulary of the Flash Language of 1812. ....flash language was the cant or slang of criminals.
"Vaux said that cheese it meant to keep quiet or to stop, desist or leave off doing something.
"Unfortunately, we don’t have such a simple explanation for cheese it. It might have been a version of cease. Jonathon Green, in the Cassell Dictionary of Slang, also points to an old proverb, after cheese comes nothing, which refers to cheese being the last item in a meal. This sounds more than a little literary and stretched, but perhaps the proverb was well enough known then that it made sense just to say 'cheese!'”
http://www.worldwidewords.org/qa/qa-che4.htm