It is also called nocturnal ejaculation and very little is known about this phenomenon. Anyhow, it is normal in males and does not indicate pathology. You should keep your mind free from sexual thinking especially at the time of going to sleep.
There are no special ways to control this condition because it is natural phenomenon which is more common in teenage boys. For details, visit this link.