The aim of the paper is to investigate finite horizon portfolio strategies which maximize a utility criterion when a constraint is imposed on a terminal date (European guarantee) or on every intermediate date (American Guarantee). We prove the optimality of the Option Based Portfolio Insurance method for both European and American cases, when an expected CRRA utility function is maximized. The American OBPI is fully described in a Black-Scholes environment as well as in the more general case of complete markets using the Gittins index techniques developed by El-Karoui and Karatzas (1995). Optimality results are extended to general utility functions.