To achieve accurate finite element (FE) analysis and to capture intricate geometric features in topology optimization using the feature mapping method, it is essential to apply extreme finely discretized background FE mesh. However, this necessity comes with increased time and memory overheads and may even lead to the failure of solving 3D problems. Consequently, this paper proposes a tailored 2:1 balanced octree meshing algorithm for topology optimization using the feature mapping method. In particular, two strategies are employed to achieve accurate mesh partitioning. The first strategy applies the exact max-min operator, rather than the smooth approximation operator used in the optimization phase, to define union, intersection, and subtraction operations between geometric components. The second strategy combines vertex function evaluation with revised affine arithmetic to rigorously check function transversality. To enhance efficiency in the latter, the function evaluation of the current mesh reuses the evaluation of the identical vertex from the sibling or parent mesh. Concurrently, only active components intersecting the parent mesh undergo checking for the current mesh, eliminating the need to checking all components. Subsequently, only meshes that intersect any one component and whose neighboring meshes share faces (edges in 2D) are balanced and numbered for structural analysis. This measure avoids numerical singularity arising from void elements and reduces extra time and memory requirements. Finally, algorithms for feature-driven topology optimization, including octree meshing, sensitivity analysis, multi-point constraint and the update of design variables using the method of moving asymptotes (MMA), are implemented on an in-house C++ framework. The feasibility and effectiveness of the proposed algorithms are demonstrated by means of benchmark 2D and 3D numerical designs.