The soft spots on the head of babies are called fontanelles. They are actually two spots -- one towards front and the other (which is smaller) is towards the back.
Before birth, these fontanelles give the baby's head the flexibility needed to be able to pass through the narrow birth canal. After the baby's born, they stay open to accommodate the growing brain of the baby.
When the bones in a baby's skull has built up enough minerals, they will completely fuse together and these gaps will close. Typically, when a baby is between 2 to 4 months old, the back fontanelles will close first. However the front one stays open until the baby's second year.