need electrical box
The boxes are REQUIRED by code. This is mostly a fire containment issue. If there is a spark, it will be contained within the box. Since they are so easy to install (and they have screw holes for the switch mounting), give yourself some peace of mind and install the box.
You absolutely need a box!!!