In this paper, we consider the risk model perturbed by a diffusion process. We assume an Erlang(n) risk process, (n = 1,2, ...) to study the Gerber-Shiu discounted penalty function when ruin is due to claims or oscillations by including a dependence structure between claim sizes and their occurrence time. We derive the integro-differential equation of the expected discounted penalty function, its Laplace transform. Then, by analyzing the roots of the generalized Lundberg equation, we show that the expected penalty function satisfies a certain defective renewal equation and provide its representation solution. Finally, we give some explicit expressions for the Gerber-Shiu discounted penalty functions when the claim size distributions are Erlang(m), (m = 1,2, ...) and provide numerical examples to illustrate the ruin probability.