A secret can be difficult to keep and equally difficult to share. Yet life seems to run on secrets. Secrets can either be good or bad. 

Secret means mystery, private or something hidden. It is something not open, not revealed, not expressed or designed to elude detection.

  • God has secrets – “He that dwelleth in the secret place of the most High shall abide under the shadow of the Almighty.” Psalm 91:1. “The LORD tells his secrets to his followers. He teaches them about his agreement.” Psalm 25:14 (ETRV) 
  • Man has secrets
  • Satan has secrets -  “And no wonder, for Satan himself masquerades as an angel of light.” 2 Corinthians 11:14 (NIV).

when to keep secret

When You Are To Keep Secrets.

1.  Sometimes, when God is sending you on an important mission, a little secrecy is needed until you accomplish it. 

There are spiritual enemies that do not like seeing you doing God's will; hence they will always strategise to see you failing God. When God gives you an assignment and He gives you directions on how to do it, if at all you must tell anyone, know the kind of person you will tell, know the kind of gathering you'll speak it. 
Jesus and his followers went to the towns in the area of Caesarea Philippi. While they were traveling, Jesus asked the followers, "Who do people say I am?" They answered, "Some people say you are John the Baptizer. Others say you are Elijah. And others say you are one of the prophets." Then Jesus asked, "Who do you say I am?" Peter answered, "You are the Messiah." Jesus told the followers, "Don't tell anyone who I am." Mark 8:27-30 (ETRV).
Why did Jesus charged His disciples not to reveal His messianic mission to people? It's because if people should be aware of this at that time, it is going to affect the thoughts and the mentality of the people, which might thwart what God had initially planned. If his people knew He was the Messiah, many would have protested and hindered his death.
The LORD commanded a man of God from Judah to go to the city of Bethel. … The LORD had commanded the man of God to speak against the altar. … When King Jeroboam heard the message from the man of God about the altar in Bethel, he took his hand off the altar and pointed at the man. He said, "Arrest that man!" But when the king said this, his arm became paralyzed. He could not move it. Then the altar broke into pieces, and all its ashes fell onto the ground. This proved that what the man of God had said came from the LORD. Then King Jeroboam said to the man of God, "Please pray to the LORD your God for me. Ask him to heal my arm." So the man of God prayed to the LORD, and the king's arm was healed, as it was before. Then the king said to the man of God, "Please come home with me. Come and eat with me. I will give you a gift." But the man of God said to the king, "I will not go home with you, even if you give me half of your kingdom! I will not eat or drink anything in this place. The LORD commanded me not to eat or drink anything here. He also commanded me not to go back the same way I came." So he took a different road home. He did not go back the same way he came to Bethel. There was an old prophet living in Bethel. His sons came and told him what the man of God did in Bethel and what he said to King Jeroboam. … The old prophet went after the man of God. He found him sitting under an oak tree and asked him, "Are you the man of God who just came from Judah?" The man of God answered, "Yes, I am." So the old prophet said, "Please come home and eat with me." But the man of God said, "I cannot go home with you. I cannot eat or drink anything in this place. The LORD said to me, 'You must not eat or drink anything in that place, and you must go back on a different road.'" The old prophet lied to him and said, "But I am a prophet like you. And an angel from the LORD came to me and told me to bring you home and give you something to eat and drink." So the man of God went to the old prophet's house and ate and drank with him. While they were sitting at the table, the LORD spoke to the old prophet, and the old prophet spoke to the man of God from Judah. He said, "The LORD said that you did not obey him! You did not do what he commanded. He told you not to eat or drink anything in this place, but you came back here and ate and drank. So your body will not be buried in your family grave." The man of God finished eating and drinking. Then the old prophet saddled the man's donkey for him and the man left. On the way home, a lion attacked and killed the man of God. His body was lying on the road while the lion stood next to it. … The old prophet heard the story and said, "This is the man of God who did not obey the LORD's command, so the LORD sent a lion to attack him. The lion has killed him, just as the LORD said would happen." 1 Kings 13:1-26 (ETRV)
The ministry of the young prophet ended unexpectedly because he refused to keep the secret within Himself. 

2.  When the enemy is seeking to know the source of your strength. 

It has always been a mystery to the devil of how Christians generate their power and strength. He wants to know what ingredients are helping you to maintain a cordial walk with the Holy Spirit. He may send someone, which you may not detect / suspect to you to be your closest friend. If you cannot pray discerning prayers on your friends, you won't know the person you ought to confide your secret in. This led to the fall of Samson.
Some time later Samson fell in love with a woman named Delilah, who lived in the valley of Sorek.  The rulers of the Philistines went to her and said, “Entice Samson to tell you what makes him so strong and how he can be overpowered and tied up securely. Then each of us will give you 1,100 pieces of silver.”  So Delilah said to Samson, “Please tell me what makes you so strong and what it would take to tie you up securely.”  … Then Delilah pouted, “How can you tell me, ‘I love you,’ when you don’t share your secrets with me? You’ve made fun of me three times now, and you still haven’t told me what makes you so strong!”  She tormented him with her nagging day after day until he was sick to death of it.  Finally, Samson shared his secret with her. “My hair has never been cut,” he confessed, “for I was dedicated to God as a Nazirite from birth. If my head were shaved, my strength would leave me, and I would become as weak as anyone else.”  Delilah realized he had finally told her the truth, so she sent for the Philistine rulers. “Come back one more time,” she said, “for he has finally told me his secret.” So the Philistine rulers returned with the money in their hands.  Delilah lulled Samson to sleep with his head in her lap, and then she called in a man to shave off the seven locks of his hair. In this way she began to bring him down, and his strength left him. Judges 16:4-19 (NLT)
He was not aware that the lady has been hired, he thought Delilah was like every other prostitute he had met.

3.  When you are surrounded by envious enemies. 

It was envy that prompted Satan to deceive man from his divine place, he was envious of the position God placed man in His heart. "And God blessed them, and God said unto them, Be fruitful, and multiply, and replenish the earth, and subdue it: and have dominion over the fish of the sea, and over the fowl of the air, and over every living thing that moveth upon the earth." Genesis 1:28. He had to force Eve to reveal the secret that made them to still stay connected with God which is their obedience of not to eat the forbidden fruit. 
The serpent was the shrewdest of all the wild animals the LORD God had made. “…Did God really say you must not eat the fruit from any of the trees in the garden?” “Of course we may eat fruit from the trees in the garden,” the woman replied. “It’s only the fruit from the tree in the middle of the garden that we are not allowed to eat. God said, ‘You must not eat it or even touch it; if you do, you will die.’” Genesis 3:1-3 (NLT).
From that secret, he manipulated and changed their notion about God. If Adam and Eve had known they had such envious enemies around, they won't have given the devil an entertaining dialogue in the first place. Whether you like it or not, there are some automatic enemies who want to have what you have, though it may be useless to them. They don't want you to have it simply because they feel you'll have an edge over them. For this reason, you must know the kind of secret you release out. In Genesis 37, Joseph's destiny initially had a zigzag because he was revealing the secret of his destiny to his brethren he never knew their disposition toward him. The Good Book says
Even members of your own family will be your enemies.' Matthew 10:36; Micah 7:6 (ETRV) 
Therefore, be decretive in sharing your secrets with so called fellow brethren, especially if you don't know much about their spiritual content. 

4.  When you are carrying the pregnancy of your testimony. 

Revealing secrets when you are about to get a good news is dangerous. A man got a contract he had not fully executed; he came to church to share the testimony to the church brethren. Unfortunately, there was this young armed robber in church that day whose wife has been pressuring to come to church perhaps he’ll hear sermons that can make him forsake his criminal activities. On hearing the testimony that fateful day, the spirit of robbery stirred up within. As soon as he got home, he contacted his gang to visit the big man. Eventually, the robbers collected the money he ought to have used to execute the contract. When God gives you an idea to do something, do it first before revealing it to another. Never be so overwhelmed to reveal God's plan over you to just anybody easily. Many at times, God manoeuvres and confuse the enemies to do a miracle, when the enemies are now in a confused state, they may come to you directly or indirectly to know the level at which God is working in your life; when you begin to reveal God's prophecies about yourself to them, it is from the words of your mouth they'll use to reinforce their own plans, and God will be very sad about it for revealing such secret. 

It is very important to know when you are to keep secrets because once it is released, it can never be undone. Know the depth of the spiritual life of the person you reveal secrets to. Someone being a worker or minister in God's vineyard does not necessarily mean such person is trustworthy because there are many wolves in sheep clothing. 
"Be careful of false prophets. They come to you and look gentle like sheep. But they are really dangerous like wolves. Matthew 7:15 (ETRV)