A chalazion is a blocked oil gland causing a painless lump, while a hordeolum (stye) is an acute infection causing a painful swelling.