Is it okay to demolish a building by setting fire to it?

No. If you have permission from your local authority or the environmental regulator to burn some timber on the site this must be done in a controlled way. Most buildings contain other materials that must not be burnt - eg asbestos containing materials, electric cables and other plastic items including foam insulation. Many timber materials can now be recycled.