Olive oil can be readily substituted in most recipes where butter or margarine is used. Infusing Olive oil and butter or margarine are sometimes combined to enhance each other's flavor in some recipes.
The conversion chart below is appropriate for most cake and pastry recipes where quantities are critical. Keep in mind, however, that it is not always a good idea to use liquid shortening (olive oil/vegetable oil) instead of solid shortening (butter/margarine). For instance, since cake frosting must stay solid at room temperature, butter and powdered sugar work nicely, but olive oil and powdered sugar don't.
You should also consider the taste factor. A mild tasting late harvest olive oil could be used in most cake and pastry recipes because cooking will get rid of the aromatic olive oil flavors. Uncooked confections such as cake frosting would taste more than a bit unusual if made with olive oil.