if you inject the entity manager, it is created, propagated and closed automatically by the container. If you inject the entity manager factory you have to perform all these steps programmatically. Therefore you'll usually inject the entity manager.
Reasons for using an entity manager factory are:
1. In a multi-threaded environment you'll prefer to use thread-safe instance variables. An entity manager factory is thread-safe, while an entity manager is not.
2. You want to use an application-managed persistence context.