When to use code based applications and when to use composite application?
Simple really: when a solution built as a Composite Application no longer suits the business requirement, modify components used in the composite application using code.
SPDoctor is right though, anything built on SharePoint is effectively a composite application. Even code-based modifications are used in the context of a composite application.
If I understand the context of your question, you probably want to work with external data not stored in Sharepoint content database. And the question is whether to build ASP.NEt application and host it under SharePoint web applicatin or do it with BCS which is native to SharePoint. The word "Composite" is being used in SharePoint documentation a lot and it refers you to BCS.
If the functionality can be achieved using BCS, I would stay away from custom code.
I came across a good article in SharePoint Pro magazine and I hope its relevant here: http://www.sharepointpromag.com/article/microsoft-products/Introduction-to-Composite-Applications-in-SharePoint-2010