We present a technique for the computation of the Green's tensor in three-dimensional stratified media composed of an arbitrary number of layers with different permittivities and permeabilities (including metals with a complex permittivity). The practical implementation of this technique is discussed in detail. In particular, we show how to efficiently handle the singularities occurring in Sommerfeld integrals, by deforming the integration path in the complex plane. Examples assess the accuracy of this approach and illustrate the physical properties of the Green's tensor, which represents the field radiated by three orthogonal dipoles embedded in the multilayered medium.