A topological derivative of the Lagrangian is required for optimization of structures with thermal and mechanical boundary conditions by the level-set method using the reaction diffusion equation. In this study, drawing on the relationship between the shape derivative and the topological derivative, the topological derivative of the Lagrangian was obtained by Reynolds' transport theorem. Given that introducing holes to the topology creates boundaries, the derivative was found by incorporating the boundary integral into the Reynolds' transport theorem and analyzing the stress over the hole boundaries. The temperature was assumed to be dependent on topology in the present study under thermal and mechanical boundary conditions. Placing a hole in the structure affects the temperature of the remaining elements. Penalty factor is enforced on thermal conductivity for removed elements, and the result is taken into consideration in the Laplace's equation expressing the steady-state conductive heat transfer.