He had no idea
But it was not always the case. The development of Frodo's entrance into Mordor is somewhat complex. In chronological order of writing:
- Gollum takes them through secret paths around the Gate.
- Frodo is captured at the Gate, Sam puts on the Ring and rescues him.
- Same story, but moved south to Cirith Ungol, Gate is closed.
One of the earliest references to how Frodo comes into Mordor is from an early outline of the end of the story. It is undated, but was probably written in 1939 and still mentions Bingo instead of Frodo.
When Bingo [written above: Frodo] at last reaches Crack and Fiery Mountain he cannot make himself throw the Ring away. ? He hears Necromancer's voice offering him great reward - to share power with him, if he will keep it.
At that moment Gollum - who had seemed to reform and had guided them by secret ways through Mordor - comes up and treacherously tries to take Ring. They wrestle and Gollum takes Ring and falls into the Crack.
The History of Middle-Earth Volume 6: The Return of the Shadow, New Uncertainties and New Projections, p. 380
It would seem that Frodo was never meant to go through an official entrance or to use the Ring to slip by.
A later sketch glosses over the entrance, but introduces Gollum's betrayal:
The Gap of Gorgoroth not far from Fire Mountain. There are Orc guard-towers on either side of Gorgoroth. They see a host of evil led by Black Riders. Gollum betrays Frodo. He is beaten off, but escapes shrieking to the Black Riders. The Black Riders now have taken form of demonic eagles and fly before host, or [? take eagle-like] vulture birds as steeds.
Frodo toils up Mountain to find Crack.
The History of Middle-Earth Volume 7: The Treason of Isengard, The Story Foreseen from Moria, p. 208
Frodo captured at the Black Gate
As Tolkien was writing this sketch, more ideas came to him:
Function for Sam? Is he to die? (He said there is something I have to do before [I die >] the end.)
Sam could get hold of the Ring. Frodo betrayed by Gollum and taken by orcs (?) to Minas Morgol. They take his ring and find it is no good; they put him in a dungeon, and threaten to send him to Baraddur.
At this time, however, the name "Minas Morgol" (later Morgul) is a different tower: it is located at the Black Gate, not in Cirith Ungol, which doesn't exist yet. It is also the only entrance into Mordor, so it would make sense for Gollum to lead them there.
Then, spiders are introduced and the story of Frodo's capture and Sam's rescue emerges.
How can Sam get hold of Ring? He keeps watch at night and hears Gollum muttering to himself, words of hatred for Frodo. He draws his sword and leaps on Gollum, [?dragging] him off. He tries to [insert utter] horrible words over Frodo - incantation of sleep. A spider charm, or does Gollum get spiders' help?
There is a ravine, a spiders' glen, they have to pass at entrance to
Gorgoroth. Gollum gets spiders to put spell of sleep on Frodo. Sam drives them off. But cannot wake him. He then gets idea of taking Ring. He sits beside Frodo. Gollum betrays Frodo to the Orc-guard. They are overwhelmed and Sam knocked silly with a club. He puts on Ring and follows Frodo. (A ring from Mazarbul would be useful.)
Sam comes and uses Ring. Passes into Morgol and finds Frodo.
It appears that the story has been the same since very early on: Frodo gets captured, Sam puts on the Ring, passes unseen into the Tower and rescues Frodo.
Story moved to Cirith Ungol, the Black Gate is closed
The major change that would later come would be to move Minas Morgul from the Black Gate to a new location: Cirith Ungol, about 150 miles south of the Gate. Thus, Frodo still comes to the Black Gate, but finds it closed and has to travel south to Cirith Ungol, where the story of the capture and rescue has been moved to.
On the development of this new chapter "The Black Gate is Closed", Christopher Tolkien says this:
This was a part of the narrative that largely 'wrote itself', and there is not a great deal to record of its development; it was achieved, also, in a much more orderly fashion than had been the case for a long time.
The History of Middle-Earth Volume 8: The War of the Ring, The Black Gate is Closed, p. 120
So your confusion about Frodo's plan is understandable: he never really discusses his path, even with Gollum. It is said in their first discussion that they need to get into Mordor, but not how. The first mention of the Black Gate is much later on, after the Dead Marshes:
"This is the last stage. Bring us to the Gate, and then I will not ask you to go further. Bring us to the Gate, and you may go where you wish – only not to our enemies.’
‘To the Gate, eh?’ Gollum squeaked, seeming surprised and frightened. ‘To the Gate, master says! Yes, he says so. And good Sméagol does what he asks, O yes. But when we gets closer, we’ll see perhaps, we’ll see then. It won’t look nice at all. O no! O no!’
The Lord of the Rings: The Two Towers, The Passage of the Marshes, p. 297
The reason for this is simple: at the time this part was written, the Black Gate was their final destination, as it was the only entrance into Mordor. After Minas Morgul was moved south, the chapters from the Black Gate to Cirith Ungol were written, but there was never any changes in the earlier story.
However, Frodo's intentions are not so difficult to understand: to him, the Black Gate is the only entrance, as he is unaware of Cirith Ungol. Therefore, it makes sense to me that he would try to get there and then see what happens.
‘I said so, because I purpose to enter Mordor, and I know no other way. Therefore I shall go this way. I do not ask anyone to go with me. [...] I am commanded to go to the land of Mordor, and therefore I shall go,’ said Frodo. ‘If there is only one way, then I must take it. What comes after must come.’
The Lord of the Rings: The Two Towers, The Black Gate is Closed, p. 301