Blockade of the human ether-à-go-go-related gene (hERG) channel by small molecules induces the prolongation of the QT interval which leads to fatal cardiotoxicity and accounts for the withdrawal or severe restrictions on the use of many approved drugs. In this study, we develop a deep learning approach, termed deephERG, for prediction of hERG blockers of small molecules in drug discovery and postmarketing surveillance. In total, we assemble 7,889 compounds with well-defined experimental data on the hERG and with diverse chemical structures. We find that deephERG models built by a multitask deep neural network (DNN) algorithm outperform those built by single-task DNN, naı̈ve Bayes (NB), support vector machine (SVM), random forest (RF), and graph convolutional neural network (GCNN). Specifically, the area under the receiver operating characteristic curve (AUC) value for the best model of deephERG is 0.967 on the validation set. Furthermore, based on 1,824 U.S. Food and Drug Administration (FDA) approved drugs, 29.6% drugs are computationally identified to have potential hERG inhibitory activities by deephERG, highlighting the importance of hERG risk assessment in early drug discovery. Finally, we showcase several novel predicted hERG blockers on approved antineoplastic agents, which are validated by clinical case reports, experimental evidence, and the literature. In summary, this study presents a powerful deep learning-based tool for risk assessment of hERG-mediated cardiotoxicities in drug discovery and postmarketing surveillance.