Ortiz's homer in 9th lifts Red Sox over Tigers 5-3