Can a person still be contageous after applying the herpes medication denavir (penciclovir)?

Yes. All medications take time to work -- and viral replication is not automatically stopped just because a medical is applied that moment. So -- they can still be infectious for some time after the medication is started (generally a few days).