Listing curriculum vitae data
Try:

ORDER BY ep.data_termino IS NOT NULL, ep.data_termino DESC, ep.data_inicio ASC


BTW,

IFNULL(ep.data_termino,NOW()) 


is a cleaner way to express:

IF(ep.data_termino IS NULL,NOW(),ep.data_termino)