Cardiac Purkinje networks are a fundamental part of the conduction system and are known to initiate a variety of cardiac arrhythmias. However, patient-specific modeling of Purkinje networks remains a challenge due to their high morphological complexity. This work presents a novel method based on optimization principles for the generation of Purkinje networks that combines geometric and electrical accuracy in branch size, bifurcation angles, and Purkinje-ventricular-junction activation times. Three biventricular meshes with increasing levels of complexity are used to evaluate the performance of our approach. Purkinje-tissue coupled monodomain simulations are executed to evaluate the generated networks in a realistic scenario using the most recent Purkinje/ventricular human cellular models and physiological values for the Purkinje-ventricular-junction characteristic delay. The results demonstrate that the new method can generate patient-specific Purkinje networks with controlled morphological metrics and specified local activation times at the Purkinje-ventricular junctions.