It is caused by heat. Heat triggers lettuce to go to seed. When that happens it generates a bitter alkaloid, sort of a natural bug poison so the seeds can mature. Lettuce is a cool weather only crop.