I am creating case comments for my cases. whould like to know how is case comments visibility is set in salesforce? is it based on the parent case. or just the IsPublished field.
Case Comments are affected by several settings. For internal users, only the case's sharing is considered. If the user can see the case, they can see all of the case comments, published or not. For portal users, they can only see the case comments if Published is true, and they are either contact on the case or a super-user for the account the case is associated with.
Case Comments are part of the case so the visibility will be based on the Case permissions. The IsPublished field (label as Public) on screen means that community and portal users are not able to view it if the IsPublished is not set.
You can remove the Related List from the Case Page layout so if you wanted a specific user profile not to view them then you could give them a profile which used a Case layout without the Case Comments related list.