There is no way to prevent a BAN on a CFW Enabled PS3 Console, there are some methods to remedy the situation, like PSN Ninja and SEN Enabler, that hide any CFW traces including syscalls, but even with these apps, you still have a big chance of getting banned by Sony.
Even if you try to play only Online, the right way (no cheats or hacks etc...) you still can get banned
There is no 100% definitive solution to remedy the situation, if Sony sees you have a CFW Consoles, you are pretty much screwed.
Best advice, dont go online on a CFW consoles, unless you dont care about or you have nothing to lose.
I remember on the PSP, you could go online, because Sony didnt care about the system, but with PS3 is a different story, even if Sony discontinued the system or doesnt support it, as long as Sony still keeps the PSN on the PS3 alive, so will CFW bans be.