The averaging theory has been extensively employed for studying periodic solutions of smooth and nonsmooth differential systems. Here, we extend the averaging theory for studying periodic solutions a class of regularly perturbed non-autonomous $n$-dimensional discontinuous piecewise smooth differential system. As a fundamental hypothesis, it is assumed that the unperturbed system has a manifold $\mathcal{Z}\subset\mathbb{R}^n$ of periodic solutions satisfying $\dim(\mathcal{Z}) < n.$ Then, we apply this result to study limit cycles bifurcating from periodic solutions of linear differential systems, $x'=Mx$, when they are perturbed inside a class of discontinuous piecewise polynomial differential systems with two zones. More precisely, we study the periodic solutions of the following differential system: $$ x'=Mx+ \varepsilon F\_1^n(x)+\varepsilon^2 F\_2^n(x), $$ in $\mathbb{R}^{d+2}$, where $\varepsilon$ is a small parameter, $M$ is a $(d+2)\times(d+2)$ matrix having one pair of pure imaginary conjugate eigenvalues, $m$ zeros eigenvalues, and $d-m$ non-zero real eigenvalues.