All sin is against Cod. In David's adultery with Bathsheba, he sinned against Bathsheba, against Uriah her husband, against his own family, and against the nation of Israel. Psalm 51 is David's confession to Jehovah. When we sin, therefore, we must first clear the record with God. He is the supreme Lawgiver, and He is the supreme Forgiver.
Many sins are against others also.
A sin against one's partner needs to be confessed to that partner. A sin against one's family needs to be confessed to the family. Private sins are dealt with in private, public sins in public. If Jack, in the former illustration, makes his unkind comment to Sam, to Sam he needs to confess it. If he makes it loudly so tat the whole group hears, it is proper for him to make his confession in the same audience.