This paper focuses on constructing ternary optimal self-orthogonal codes with \(k\le 6\) . Firstly, we generalize the method of constructing linear codes to obtain a general method for constructing self-orthogonal codes. Secondly, optimal self-orthogonal codes with all lengths on \(k=2,3,4,5\) are constructed, except for two codes. Moreover, some 6-dimensional optimal self-orthogonal codes with lengths \(n\le 100\) and \(254\le n\le 364\) are obtained. Finally, we obtain distance formulas for ternary optimal self-orthogonal codes according to the construction results.