Yes, it was wrong for your pastor to betray your trust by telling others about the conversation you had with him -- a conversation you assumed would be in confidence. We all need to keep confidences, and this is especially true for those who've been called to serve others in Christ's name. The Bible says, "A gossip betrays a confidence, but a trustworthy man keeps a secret" (Proverbs 11:13).
I can only speculate why he did this (if he even stopped to think about it). Perhaps he's just young and inexperienced; perhaps in a weak moment he gave in to the temptation to show off by letting others know he knew something they didn't know. But whatever the reason, what he did was wrong, and he not only hurt you but he also hurt himself and his ministry. Will others now feel free to tell him their problems? I doubt it.
What should you do? First, I suggest you let him know of your disappointment (perhaps in a brief note) -- not out of anger, but because you want to help him. Then ask God to help you overcome your feelings about him, and to forgive him. Don't let this become a barrier that cuts you off from your church's ministry.
Then learn to turn your problems over to Christ, seeking His wisdom for their solution. Sometimes He gives it through others; sometimes it comes as we pray and read the Bible. The Bible says, "Your word is a lamp to my feet and a light for my path" (Psalm 119:105).