A search for second and third generation scalar and vector leptoquarks produced in ep collisions via the lepton flavour violating processes ep -> mu X and ep -> tau X is performed by the H1 experiment at HERA. The full data sample taken at a centre-of-mass energy root s = 319 GeV is used for the analysis, corresponding to an integrated luminosity of 245 pb(-1) of e(+)p and 166 pb(-1) of e(-)p collision data. No evidence for the production of such leptoquarks is observed in the H1 data. Leptoquarks produced in e(+/-)p collisions with a coupling strength of lambda = 0.3 and decaying with the same coupling strength to a muon-quark pair or a tau-quark pair are excluded at 95% confidence level up to leptoquark masses of 712 GeV and 479 GeV, respectively. (C) 2011 Elsevier B.V. All rights reserved.