We characterize the second order subexponentiality of an infinitely divisible distribution on the real line under an exponential moment assumption. We investigate the asymptotic behaviour of the difference between the tails of an infinitely divisible distribution and its Lévy measure. Moreover, we study the second order asymptotic behaviour of the tail of the $t$th convolution power of an infinitely divisible distribution. The density version for a self-decomposable distribution on the real line without an exponential moment assumption is also given. Finally, the regularly varying case for a self-decomposable distribution on the half line is discussed.