To do so, please go to the main menu and select Options and then select Online.
Then go down to the option labeled Online Invasions
And switch this option to Off. Please be warned that if you disable this option you will not be able to participate in Online Hacking or Tailing.
Additionally, any Notoriety points you've earned whilst playing online will be reset.
You'll be presented with the following warning when you attempt to turn off Online Invasions.