There is unfortunately no way to get your child back once it was taken away by the social worker. Your child will be available for adoption by other families, but any Sim which has the "Child taken away" memory will never be able to adopt a child.
To avoid this happening in the future, here is when the social worker will take your child away:
- When the child's needs are too low;
- When a child has an F in school;
- When a child is left home alone;
- When a child is too hot or too cold (only with the Seasons expansion pack).
A social worker can take away a baby, a toddler or a child, and will take away all children below teenager level in one visit.
The only way to stop a social worker from taking a child away is to use the "Plead with social worker" interaction, which is only available if you have the Free Time expansion pack, via a lifetime aspiration benefit. The social worker has the ability to teleport the children, so shielding them doesn't work.