The correct sealant must be used for any application. Sealants have specific properties to for the application intended. They can be used to withstand high pressure or high temperature. Some sealants are for oil, while other are meant for water/coolant. Sealants may be silicone based, however the stuff made for household purposes is no good in automotive use. It is neither oil resistant nor heat resistant.
Sealants will either be OEM specific or generic. High quality generic sealants can in most cases replace OEM specific sealants. Where a specific OEM sealant is required the generic sealant must conform to the specifications documented by the manufacturer. Use the specification sheets to look into which generic sealant is compatible with which OEM sealant.
While applying sealant, avoid using the "more is better" method. Excess sealant after pressing the mating surfaces together can cause contamination or blockage of oil and water passages. For this reason, many of the modern sealants dissolve when coming in contact with oil and water. Also the temperature at which the sealant is applied and cured must be according to the sealant specifications.
Ensure that the mating surfaces are straight. Check surfaces with a straight-edge and refinish surface if needed. For oil pans the pan's edge can be carefully hammered on a flat surface. For thicker materials a sanding using a flat block may be necessary. For cylinder heads and cylinder blocks, these must be leveled using the correct tools. Correct thickness must be observed of the head, block and gasket to ensure correct compression ratio.
Also ensure that the mating surfaces are clear of contaminants prior to applying the sealant. Failure of correct bonding to the surfaces will result in a leak. Old oil residue left on the mating surface will also result in poor bonding of the sealant.