Progresses in additive manufacturing technologies allow the realization of finely graded microstructured materials with tunable mechanical properties. This paves the way to a wealth of innovative applications, calling for the combined design of the macroscopic mechanical piece and its underlying microstructure. In this context, we investigate a topology optimization problem for an elastic medium featuring a periodic microstructure. The optimization problem is variationally formulated as a bilevel minimization of phase-field type. By resorting to Γ -convergence techniques, we characterize the homogenized problem and investigate the corresponding sharp-interface limit. First-order optimality conditions are derived, both at the homogenized phase-field and at the sharp-interface level.