I believe the example referenced from John 4 demonstrates exactly the purpose Paul has in mind here. Let's compare the two:
From the OP:
he is called to account
From John 4:
16 Jesus saith unto her, Go, call thy husband, and come hither.
--
From the OP:
the secrets of his heart are disclosed
From John 4:
17 The woman answered and said, I have no husband. Jesus said unto
her, Thou hast well said, I have no husband:
18 For thou hast had five husbands; and he whom thou now hast is not
thy husband: in that saidst thou truly.
--
From the OP:
he will worship God
From John 4:
23 ...true worshippers shall worship the Father in spirit and in truth...
--
From the OP:
he will...declare that God is really among you
From John 4:
19 The woman saith unto him, Sir, I perceive that thou art a prophet.
[He has her attention now]
25 The woman saith unto him, I know that Messias cometh, which is
called Christ: when he is come, he will tell us all things.
[She's starting to get it]
26 Jesus saith unto her, I that speak unto thee am he.
28 The woman then left her waterpot, and went her way into the city,
and saith to the men,
29 Come, see a man, which told me all things that ever I did: is not
this the Christ?
[She got it]
--
What's the purpose?
Jesus' purpose here was not to show off spiritual gifts or divine abilities--notice that this call to repentance was done in private (see vs. 8). Jesus did on occasion call people to repentance more publicly (e.g. Matthew 23), but this appears to have been at least in part to protect innocent parties from sinful religious leaders.
Jesus wanted to help this woman repent, understand how to worship, and recognize that the Messiah and His message were here. His rather bold statement about her sins got her attention; Jesus then helped her connect the dots among truths she already knew, and bore plain testimony of the truth she needed to hear.
As noted in other answers, the purpose is not to humiliate someone, but to bring them to repentance. I agree with Dottard's assessment that the Holy Ghost "convicts" the sinner and pricks their heart in a way that human wisdom alone cannot. This is demonstrated in Acts 2:
37 Now when they heard this, they were pricked in their heart, and
said unto Peter and to the rest of the apostles, Men and brethren,
what shall we do?
Peter is clearly being directed by the Spirit in this chapter, and he spoke directly and effectively in a call to repentance that penetrated their hearts. The audience is now ready to act.
--
Not a cookie-cutter preacher
The "if" in 1 Cor 14:24 is important--this method of preaching repentance is appropriate if the Spirit directs. Paul himself acknowledged a few chapters prior:
To the weak became I as weak, that I might gain the weak: I am made
all things to all men, that I might by all means save some. (1 Cor.
9:22, see also vss. 19-21)
--
Conclusion
Paul was willing to adopt whatever approach to preaching was needful in order to bring people to Christ--and in some cases that meant the method demonstrated by Jesus in John chapter 4.