Any off flavours in a finished beer is the result of contamination or excessive heat during fermentation. This could be caused by the water you’ve used in the brew, poor hygiene or exposure to contaminants late in fermentation, or during bottling; If only the odd bottle tastes “off” then the problem is with your bottle hygiene or splashing during bottling.
Should the whole batch taste crook, pay more attention to your method of brewing and sterilisation next time. For instance, a common contamination often comes at the end of fermentation. That is if you were to open your drum very late, then reseal it and leave for a few days prior to bottling, allowing oxygen in and bacteria to grow. Chances are there will be a white film on the surface of the brew when you go to bottle, this form of contamination can also appear in the bottles.
A good tip is to always bottle as soon as possible after fermentation finishes!