There are three distinct situations in which you may or must or may not or must not divulge a secret confided in you. The first situation is this: If you are a member of certain professions you are bound by law to hold confidences therefore it is wrong and a breach of moral and professional ethics to divulge secrets confided in you.
It is equally wrong and morally unethical to divulge secrets confided in you out of a motive of maliciousness, pettiness or destructiveness, or even carelessness or irresponsibility. In other words, if your motive for divulging a secret in any way disregards the dignity of the other or actively seeks to harm in any way the other, it is wrong to divulge a secret.
The second situation, as others have pointed out, is when the well-fare of the other person or your own well-fare requires that you must divulge secrets to older, wiser, more authoritative or more directly concerned persons. One reason this is true is that your are first of all a co-partner in the individual's safety and well-being if a secret is told to you, thus your life would be forever marred with guilt if your silence made you a partner to harm befalling anyone.
The third situation is also one in which you must divulge secrets. This is when secrets are shared with little or no concern for the hearer. From such secrets you would be burdened with information not in keeping with your own well-being. In a more serious vein, a secret might reveal plans for malicious or illegal activity. In this case, the secret, if kept and not divulged, might make you an accomplice to the malice or crime.