They are not permitted to trade for a pin with a name or relationship on it (such as "Bob" or "Grandmother")
They are not permitted to trade for a single pin that is otherwise part of a set and does not stand alone (such as a "2" from a 4-pin set saying "2005")
Generally anytime, but if a CM is busy with a customer -- such as operating a register or answering questions -- it's common courtesy to wait until the other guests have been helped and that CM is free.
You can approach a cast member at any time. I am (still) teaching my children not to pester a CM for pins when they are working with another guest (like inside a store), but you can ask them anytime, anywhere.