One of those sayings that you stole somewhere, and it develops into a whole philosophy with your current circle of friends. This particular one came from Disney's "The Emperor's New Groove." I guess originaly anytime we would say or think something sexual or perverse, we would ask for our hand to be slapped for punishment. After watching the movie it became accustomed to slap the hand and say "bad llama." Now a general "bad llama" is acceptable.

Generally usage goes something like this.

Friend: And so I said to the...
(Gorgeous girl walks past.)
You: I'm sorry I didn't hear what you were saying. (glance back at the girl.) Bad Llama! (SLAP)