A methodology for obtaining the optimal structure and distribution for the gradient properties of a material in order to reduce the stress level in a soldered joint was constructed. The developed methodology was based on a combination of topological optimization methods (the moving asymptotes method) and the finite elements method; it was first implemented to solve problems of optimizing soldered joints. Using the proposed methodology, a number of problems were solved, allowing one to obtain optimal structural characteristics, in which a decrease in stress is revealed. Designing compounds using this technique will provide more robust designs. The proposed technique can be applied to a wide class of practical problems.