Optimal generation of entanglement under local control