We obtain a characterization on self-orthogonality for a given binary linear code in terms of the number of column vectors in its generator matrix, which extends the result of Bouyukliev et al. (2006). As an application, we give an algorithmic method to embed a given binary $k$-dimensional linear code $mathcal{C}$ ($k = 2,3,4$) into a self-orthogonal code of the shortest length which has the same dimension $k$ and minimum distance $d ge d(mathcal{C})$. For $k > 4$, we suggest a recursive method to embed a $k$-dimensional linear code to a self-orthogonal code. We also give new explicit formulas for the minimum distances of optimal self-orthogonal codes for any length $n$ with dimension 4 and any length $n otequiv 6,13,14,21,22,28,29 pmod{31}$ with dimension 5. We determine the exact optimal minimum distances of $[n,4]$ self-orthogonal codes which were left open by Li-Xu-Zhao (2008) when $n equiv 0,3,4,5,10,11,12 pmod{15}$. Then, using MAGMA, we observe that our embedding sends an optimal linear code to an optimal self-orthogonal code.