Drupal 7 Forum - Allow Users to 'hide' their online status
You can use hook_block_view_alter to alter the content that is returned by who's online block. Ideally use the same logic that was implemented in user.module user_block_view function, delta who's online block but with extra validations.

Add a field called Show online status to User Profile. Let's say yes or no.

Read the above field value in the alter function for all users online and filter them before displaying.

Hope it solves !