My guess is the icing you are piping on top is too thick. There needs to be a certain amount of moistness to it to stick. So I'd try loosening it a touch next time. But, I agree with @Econlady, it's relatively uncommon for this to happen on an iced cookie. Much more common on a bare cookie.