Trick or treat was an Earth custom in which costumed children traveled from home to home on Halloween asking for treats such as candy with the question "Trick or treat?" The "trick" was a (harmless) threat to perform mischief on the homeowners if no treat was given.
After Scotty and Hikaru Sulu disappeared on Pyris VII and Jackson was killed there in 2267, Captain James Kirk said under other circumstances he would wonder if someone were "playing an elaborate trick or treat." Spock did not understand the reference but Kirk informed him he would be a natural, due to his Vulcan features. Doctor McCoy took the point well, particularly upon later finding himself chained up in a dungeon next to a skeleton. Korob however also had no understanding of trick or treat, and dismissed it as being of no importance. (TOS: "Catspaw")