Modify USB profile to remove serial port - With switch (Leonardo)

But I would like to had a switch on the leonardo that disables serial port when off and enables it when on.

This is the case with my Leonardo. It doesn't show a device when the Leonardo is off and it shows one if the Leonardo is on.

I guess you meant something different but you must describe it in more detail so I also get a clue of what you're trying to achieve.