Soliloquies and monologues have one thing in common: they each involve a solitary speaker. The difference between the two doesn't have to do with who's talking but with who's listening.
A monologue — from the Greek monos ("single") and legein ("to speak") — is a speech given by a single person to an audience. Marc Antony delivers a well-known monologue to the people of Rome in Shakespeare's Julius Caesar. You probably know how it starts:
Friends, Romans, countrymen, lend me your ears;
I come to bury Caesar, not to praise him.
The evil that men do lives after them;
The good is oft interred with their bones:
So let it be with Caesar. (etc.)
A monologue might be delivered to an audience within a play, as it is with Antony's speech, or it might be delivered directly to the audience sitting in the theater and watching the play.
But a soliloquy — from the Latin solus ("alone") and loqui ("to speak") — is a speech that one gives to oneself. In a play, a character delivering a soliloquy talks to herself — thinking out loud, as it were — so that the audience better understands what is happening to the character internally.
The most well-known soliloquy in the English language appears in Act III, Scene 1 of Hamlet:
To be, or not to be, — that is the question: —
Whether 'tis nobler in the mind to suffer
The slings and arrows of outrageous fortune
Or to take arms against a sea of troubles,
And by opposing end them? (etc.)