Painters use caulk and spackling compound to fill gaps and holes, but that's about all these two materials have in common. Whereas caulk is a flexible coating that resists moisture, spackling compound dries hard and isn't water-resistant. As a rule of thumb, caulk is best for corners and joints while spackling compound is a filler for small holes, dents and cracks -- but it isn't unusual for painters to adapt these materials for special needs.
"Spackling compound" is a catchall term for a variety of types of wood and drywall fillers. "Spackle" is the brand name for a product consisting of clay, calcium carbonate and vinyl polymers. Other products contain similar ingredients or may have a higher concentration of vinyl to give them a lighter weight and shorter drying time. Even drywall joint compound, which is a gypsum product, can serve as spackling compound, as can some latex- or solvent-based wood fillers. All these products dry hard and can be sanded, making them useful for patching holes on flat surfaces prior to painting.
Diversity also exists in the world of caulks; some are silicone-based, some are latex-based and others have different chemical compositions altogether. In general, caulk is flexible when you apply it, it retains flexibility after it cures and it has strong adhesive properties -- you can use some types of caulk to glue things together. Because it is flexible and sticks well, you must apply it with a caulking gun, not a putty knife, and you can't sand it, even after it has fully cured. You can paint over some caulks but not all of them.
Caulking Vs. Spackling
Because it's so flexible and you can't sand it, caulk isn't the ideal material for filling holes. You should instead do that with a quick application of spackling compound, using a putty knife. Spackling compound is also the material to use to repair chips in wood -- it's stiffer than caulk yet pliable enough to mold, and you can shape it with sandpaper after it dries. Caulk is the material you need when you want to fill gaps around wood trim and molding or when you want to provide a weather-resistant seal around a door or window.
Applying spackling compound is a straightforward procedure -- scrape it on with a putty knife, wait for it to dry, then sand it flat -- but the procedure for applying caulk is a bit more involved. Because caulk is designed to seal long gaps, you generally apply it in a continuous bead with a caulking gun in a two-step process. The first step is to apply the bead, and the second is to tool it by running your finger along it to create a convex surface. After that, you allow the caulk to dry. If it isn't silicone, you can paint it.